add option to not autorun root

This commit is contained in:
Daylin Morgan 2024-11-11 13:03:17 -06:00
parent e8e090c5b7
commit 292bddd59f
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 8 additions and 9 deletions

View file

@ -126,9 +126,10 @@ type
type type
# ---- # ----
CliSetting* = enum CliSetting* = enum
NoHelpFlag, ## Remove the builtin help flag GenerateOnly, ## Don't attach root `runProc()` node
ShowHelp, ## If cmdline empty show help NoHelpFlag, ## Remove the builtin help flag
NoNormalize ## Don't normalize flags and commands ShowHelp, ## If cmdline empty show help
NoNormalize ## Don't normalize flags and commands
BuiltinFlag = object BuiltinFlag = object
name*: string name*: string
@ -779,9 +780,11 @@ func hwylCliImpl(cfg: CliCfg): NimNode =
let `args` {.used.} = `parserProcName`(`cmdLine`) let `args` {.used.} = `parserProcName`(`cmdLine`)
`runBody` `runBody`
# if cfg.root and (GenerateOnly notin cfg.settings):
if cfg.root: if cfg.root:
result.add quote do: if GenerateOnly notin cfg.settings:
`runProcName`() result.add quote do:
`runProcName`()
else: else:
result.add quote do: result.add quote do:
`runProcName`(`args`[1..^1]) `runProcName`(`args`[1..^1])

View file

@ -56,9 +56,6 @@ hwylCli:
a longer mulitline description that will be visible in the subcommand help a longer mulitline description that will be visible in the subcommand help
and it will automatically be "bb"'ed [bold]this is bold text[/] and it will automatically be "bb"'ed [bold]this is bold text[/]
""" """
flags: flags:
a: a:
@ -72,4 +69,3 @@ hwylCli:
echo "hello from `example b` command" echo "hello from `example b` command"
echo fmt"{a=}, {b=}" echo fmt"{a=}, {b=}"