mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-12-22 03:00:43 -06:00
pass preSub/postSub down to children commands
This commit is contained in:
parent
ef573dc0f8
commit
186dab6d84
2 changed files with 9 additions and 3 deletions
|
@ -516,6 +516,11 @@ func pasrseCliAlias(cfg: var CliCfg, node: NimNode) =
|
||||||
|
|
||||||
func propagate(c: var CliCfg) =
|
func propagate(c: var CliCfg) =
|
||||||
for child in c.subcommands.mitems:
|
for child in c.subcommands.mitems:
|
||||||
|
# push the preSub to the lowest subcommand
|
||||||
|
if child.subcommands.len != 0 and child.preSub == nil:
|
||||||
|
child.preSub = c.preSub
|
||||||
|
child.postSub = c.postSub
|
||||||
|
else:
|
||||||
child.pre = c.preSub
|
child.pre = c.preSub
|
||||||
child.post = c.postSub
|
child.post = c.postSub
|
||||||
child.inheritFrom(c)
|
child.inheritFrom(c)
|
||||||
|
|
|
@ -25,7 +25,7 @@ hwylCli:
|
||||||
? "path to config file"
|
? "path to config file"
|
||||||
* @["config.yml"]
|
* @["config.yml"]
|
||||||
preSub:
|
preSub:
|
||||||
echo "this is run after subcommand parsing but before its run block"
|
echo "this is run after subcommand parsing but before final run block"
|
||||||
echo fmt"{yes=}, {color=}"
|
echo fmt"{yes=}, {color=}"
|
||||||
run:
|
run:
|
||||||
echo "this is always run prior to subcommand parsing"
|
echo "this is always run prior to subcommand parsing"
|
||||||
|
@ -53,6 +53,7 @@ hwylCli:
|
||||||
flags:
|
flags:
|
||||||
^config
|
^config
|
||||||
run:
|
run:
|
||||||
|
echo "hello from `example one subsub` command"
|
||||||
echo fmt"{color=}"
|
echo fmt"{color=}"
|
||||||
|
|
||||||
run:
|
run:
|
||||||
|
|
Loading…
Reference in a new issue