Re: [PATCH v2 09/20] parse-options: add support for parsing subcommands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 19 2022, SZEDER Gábor wrote:

> @@ -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...

>  	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.'





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux