Re: [PATCH v2 09/20] parse-options: add support for parsing subcommands
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Aug 19, 2022, 19:03 UTC
- Message-ID
- <220819.86h7285a1o.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <20220819160411.1791200-10-szeder.dev@gmail.com>
On Fri, Aug 19 2022, SZEDER Gábor wrote:
Show 6 quoted lines
> @@ -885,7 +977,14 @@ int parse_options(int argc, const char **argv, > case PARSE_OPT_COMPLETE: > exit(0); > case PARSE_OPT_NON_OPTION: > + case PARSE_OPT_SUBCOMMAND: > + break;
This amounts to the same behavior, because...
Show 7 quoted lines
> case PARSE_OPT_DONE:
> + if (ctx.has_subcommands &&
> + !(flags & PARSE_OPT_SUBCOMMAND_OPTIONAL)) {
> + error(_("need a subcommand"));
> + usage_with_options(usagestr, options);
> + }
> break;...AFAICT we won't have PARSE_OPT_NON_OPTION *and* ctx.has_subcommands, but it's really confusing that before we'd fall through from PARSE_OPT_NON_OPTION to PARSE_OPT_DONE, but now we don't.'