On Mon, Jun 23, 2008 at 09:09:35PM +0000, Pierre Habouzit wrote: > { > struct parse_opt_ctx_t ctx; > > parse_options_start(&ctx, argc, argv, 0); > > for (;;) { > const char *arg; > > switch (parse_options_step(&ctx, options, usagestr)) { > case PARSE_OPT_HELP: > /* dump your help here, the one for options/usagestr is already dumped */ At the expense of reworking how help is output, especially in the line above, we also can have the nice feature that you can chain parse_options_step with different options structure basically this way (error handling removed): if (parse_options_step(&ctx, options1) == PARSE_OPT_UNKNOWN && parse_options_step(&ctx, options2) == PARSE_OPT_UNKNOWN && ... parse_options_step(&ctx, options_n) == PARSE_OPT_UNKNOWN) { /* you're on ! */ } But with the proposed series, it's not possible (well in the sense that for valid command lines it will work, but you'll end up with funny usage dumps for invalid ones). -- ·O· Pierre Habouzit ··O madcoder@xxxxxxxxxx OOO http://www.madism.org
Attachment:
pgpr5PTn7W15Z.pgp
Description: PGP signature