You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: Can you implement subcomands using with this library? #34
Activity
cofyc commentedon Sep 7, 2020
no builtin support, but it's easy to implement, e.g.
a-random-lemurian commentedon Feb 9, 2022
Are there plans to add subcommand support to the library?
P.S. Oh, there was a closed issue about subcommands.
cofyc commentedon Feb 10, 2022
no, however you can follow this example
a-random-lemurian commentedon Feb 10, 2022
that example just causes a segfault when I
cmd->fn(argc, argv), what should I put in place of// run the command?P.S I finally got a working example.... I'm gonna push it real quick
P.S[2] Here's the working example https://github.com/a-random-lemurian/uselinux/blob/main/src/rmbloat/rmbloat.c
cofyc commentedon Feb 10, 2022
I also create a full example here: https://github.com/cofyc/argparse/blob/master/tests/subcommands.c
a-random-lemurian commentedon Feb 10, 2022
LGTM, but unfortunately it doesn't say anything about adding options to the subcommands themselves.
cofyc commentedon Feb 11, 2022
If you need to parse arguments for subcommand, you can init and config
argparseto parse arguments in the same way as in the main program.cofyc commentedon Feb 11, 2022
the example is updated, see the latest version.
Note that
ARGPARSE_STOP_AT_NON_OPTIONmust be passed toargparse_initin the main program.