Compare commits

..

4 commits

Author SHA1 Message Date
e8e090c5b7
actually use param 2024-11-10 16:19:44 -06:00
31012dffbf
add todo 2024-11-10 12:54:30 -06:00
f16cbaaee8
no declared not used warnings 2024-11-10 12:53:47 -06:00
cddbf5ee1e
change newline insertion 2024-11-10 12:37:56 -06:00
3 changed files with 5 additions and 4 deletions

View file

@ -64,7 +64,6 @@ 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 & "]"
@ -102,8 +101,8 @@ func render*(cli: HwylCliHelp): string =
result.add "\n" result.add "\n"
result.add cli.desc result.add cli.desc
result.add "\n" result.add "\n"
if cli.subcmds.len > 0:
result.add "\n" result.add "\n"
if cli.subcmds.len > 0:
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:
@ -409,7 +408,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 = true result.root = root
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
@ -777,7 +776,7 @@ func hwylCliImpl(cfg: CliCfg): NimNode =
`parserBody` `parserBody`
proc `runProcName`(`cmdLine`: openArray[string] = commandLineParams()) = proc `runProcName`(`cmdLine`: openArray[string] = commandLineParams()) =
let `args` = `parserProcName`(`cmdLine`) let `args` {.used.} = `parserProcName`(`cmdLine`)
`runBody` `runBody`
if cfg.root: if cfg.root:

View file

@ -45,6 +45,7 @@ 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=}"

View file

@ -17,6 +17,7 @@
### 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