const parser = comptime Clap(Options).Builder
.init(
Options {
.print_values = false,
.a = 0,
.b = 0,
.c = 0,
}
)
.command(
Command.Builder
.init("com")
.arguments(
[]Argument {
Argument.Builder
.init("a")
.help("Set the a field of Option.")
.short('a')
.takesValue(true)
.build(),
}
)
.subCommands(
[]Command {
Command.Builder
.init("sub-com")
.arguments(
[]Argument {
Argument.Builder
.init("b")
.help("Set the a field of Option.")
.short('b')
.takesValue(true)
.build(),
}
)
.build()
}
)
.build()
)
.build();
Subcommands have their own options, which cannot be accessed by their parent. com -a 1 sub-com -b 1 works, but com -a 1 -b 1 does not.
Questions:
Should sub commands be able to access the options of its parent?
com sub-com -a 1 -b 1
We could have an option that allows/disallows this.
It would probably be useful to be able to tell from the resulting struct that a subcommand was parse.
Should it just set some boolean field? Maybe subcommands will have sub results, which could be their own struct (or union, which would allow for all subcommands to return different tags of the same union).
Allow the clap to parse subcommands.
Subcommands have their own options, which cannot be accessed by their parent.
com -a 1 sub-com -b 1
works, butcom -a 1 -b 1
does not.Questions:
com sub-com -a 1 -b 1