mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-12-22 03:00:43 -06:00
fix positional handling
This commit is contained in:
parent
748f7e1bd6
commit
c5f70cec4e
2 changed files with 13 additions and 10 deletions
|
@ -856,8 +856,8 @@ func setFlagVars(cfg: CliCfg): NimNode =
|
||||||
else: cfg.flags.filterIt(it.group != "global")
|
else: cfg.flags.filterIt(it.group != "global")
|
||||||
|
|
||||||
result.add flags.mapIt(
|
result.add flags.mapIt(
|
||||||
nnkIdentDefs.newTree(it.ident, it.typeNode, newEmptyNode())
|
nnkIdentDefs.newTree(it.ident, it.typeNode, newEmptyNode())
|
||||||
)
|
)
|
||||||
|
|
||||||
func literalFlags(f: CliFlag): NimNode =
|
func literalFlags(f: CliFlag): NimNode =
|
||||||
var flags: seq[string]
|
var flags: seq[string]
|
||||||
|
@ -932,13 +932,13 @@ func parseArgs[T](p: OptParser, target: var seq[T]) =
|
||||||
|
|
||||||
func argOfBranch(cfg: CliCfg): NimNode =
|
func argOfBranch(cfg: CliCfg): NimNode =
|
||||||
result = nnkOfBranch.newTree(ident"cmdArgument")
|
result = nnkOfBranch.newTree(ident"cmdArgument")
|
||||||
if cfg.args.len == 0 and cfg.subcommands.len == 0:
|
# if cfg.args.len == 0 and cfg.subcommands.len == 0:
|
||||||
result.add quote do:
|
# result.add quote do:
|
||||||
hwylCliError("unexpected positional argument: [b]" & p.key)
|
# hwylCliError("unexpected positional argument: [b]" & p.key)
|
||||||
else:
|
# else:
|
||||||
result.add quote do:
|
result.add quote do:
|
||||||
inc nArgs
|
inc nArgs
|
||||||
parseArgs(p, result)
|
parseArgs(p, result)
|
||||||
|
|
||||||
|
|
||||||
func hwylCliImpl(cfg: CliCfg): NimNode =
|
func hwylCliImpl(cfg: CliCfg): NimNode =
|
||||||
|
|
|
@ -78,7 +78,10 @@ hwylCli:
|
||||||
T seq[float]
|
T seq[float]
|
||||||
? "multiple floats"
|
? "multiple floats"
|
||||||
h "this will override the builtin 'h' for help"
|
h "this will override the builtin 'h' for help"
|
||||||
|
def:
|
||||||
|
? "a flag with a string default"
|
||||||
|
* "the value"
|
||||||
run:
|
run:
|
||||||
echo "hello from `example b` command"
|
echo "hello from `example b` command"
|
||||||
echo fmt"{thing=}, {b=}"
|
echo fmt"{thing=}, {b=}, {h=}, {def=}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue