mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-12-22 11:00:45 -06:00
Compare commits
No commits in common. "e8e090c5b76bc555231bda536193df6f92a54db2" and "69ae06fa4765e840403c61f8d34c4b7484b9dc56" have entirely different histories.
e8e090c5b7
...
69ae06fa47
3 changed files with 4 additions and 5 deletions
|
@ -64,6 +64,7 @@ func render*(cli: HwylCliHelp, f: HwylFlagHelp): string =
|
||||||
result.add "[/]"
|
result.add "[/]"
|
||||||
else:
|
else:
|
||||||
result.add " ".repeat(1 + cli.shortArgLen)
|
result.add " ".repeat(1 + cli.shortArgLen)
|
||||||
|
|
||||||
result.add " "
|
result.add " "
|
||||||
if f.long != "":
|
if f.long != "":
|
||||||
result.add "[" & cli.styles.flagLong & "]"
|
result.add "[" & cli.styles.flagLong & "]"
|
||||||
|
@ -100,9 +101,9 @@ func render*(cli: HwylCliHelp): string =
|
||||||
if cli.desc != "":
|
if cli.desc != "":
|
||||||
result.add "\n"
|
result.add "\n"
|
||||||
result.add cli.desc
|
result.add cli.desc
|
||||||
result.add "\n"
|
|
||||||
result.add "\n"
|
result.add "\n"
|
||||||
if cli.subcmds.len > 0:
|
if cli.subcmds.len > 0:
|
||||||
|
result.add "\n"
|
||||||
result.add "[" & cli.styles.header & "]"
|
result.add "[" & cli.styles.header & "]"
|
||||||
result.add "subcommands[/]:\n"
|
result.add "subcommands[/]:\n"
|
||||||
for s in cli.subcmds:
|
for s in cli.subcmds:
|
||||||
|
@ -408,7 +409,7 @@ func addBuiltinFlags(cfg: var CliCfg) =
|
||||||
|
|
||||||
func parseCliBody(body: NimNode, name = "", root = false): CliCfg =
|
func parseCliBody(body: NimNode, name = "", root = false): CliCfg =
|
||||||
result.name = name
|
result.name = name
|
||||||
result.root = root
|
result.root = true
|
||||||
for call in body:
|
for call in body:
|
||||||
if call.kind notin [nnkCall, nnkCommand, nnkPrefix]:
|
if call.kind notin [nnkCall, nnkCommand, nnkPrefix]:
|
||||||
error "unexpected node kind: " & $call.kind
|
error "unexpected node kind: " & $call.kind
|
||||||
|
@ -776,7 +777,7 @@ func hwylCliImpl(cfg: CliCfg): NimNode =
|
||||||
`parserBody`
|
`parserBody`
|
||||||
|
|
||||||
proc `runProcName`(`cmdLine`: openArray[string] = commandLineParams()) =
|
proc `runProcName`(`cmdLine`: openArray[string] = commandLineParams()) =
|
||||||
let `args` {.used.} = `parserProcName`(`cmdLine`)
|
let `args` = `parserProcName`(`cmdLine`)
|
||||||
`runBody`
|
`runBody`
|
||||||
|
|
||||||
if cfg.root:
|
if cfg.root:
|
||||||
|
|
|
@ -45,7 +45,6 @@ hwylCli:
|
||||||
^[config]
|
^[config]
|
||||||
run:
|
run:
|
||||||
echo "hello from `example one` command!"
|
echo "hello from `example one` command!"
|
||||||
echo args
|
|
||||||
echo fmt"{color=}"
|
echo fmt"{color=}"
|
||||||
echo fmt"{verbose=}"
|
echo fmt"{verbose=}"
|
||||||
echo fmt"{config=}"
|
echo fmt"{config=}"
|
||||||
|
|
1
todo.md
1
todo.md
|
@ -17,7 +17,6 @@
|
||||||
### cli generator
|
### cli generator
|
||||||
|
|
||||||
- [ ] add support for types(metavars)/defaults/required in help output
|
- [ ] add support for types(metavars)/defaults/required in help output
|
||||||
- [ ] add nargs to CliCfg
|
|
||||||
|
|
||||||
|
|
||||||
## features
|
## features
|
||||||
|
|
Loading…
Reference in a new issue