Re: [PATCH v2 04/20] t0040-parse-options: test parse_options() with various 'parse_opt_flags'
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Aug 20, 2022, 11:14 UTC
- Message-ID
- <20220820111422.GE3373722@szeder.dev>
- In-Reply-To
- <220819.86k0746t7v.gmgdl@evledraar.gmail.com>
On Fri, Aug 19, 2022 at 07:23:44PM +0200, Ævar Arnfjörð Bjarmason wrote:
> > + error("'cmd' is mandatory");
> > + usage_with_options(usage, test_flag_options);
>
> I think you want usage_msg_opt() instead.As I responded to a similar remark in the previous round, parse-options uses the "error:" prefix in its error messages:
$ ./t/helper/test-tool parse-options -U error: unknown switch `U' $ ./t/helper/test-tool parse-options --unknown error: unknown option `unknown' $ ./t/helper/test-tool parse-options -i error: switch `i' requires a value $ ./t/helper/test-tool parse-options --int error: option `integer' requires a value $ ./t/helper/test-tool parse-options -i foo error: switch `i' expects a numerical value $ ./t/helper/test-tool parse-options --int foo error: option `integer' expects a numerical value $ ./t/helper/test-tool parse-options --quiet=42 error: option `quiet' takes no value $ ./t/helper/test-tool parse-options --mode1 --mode2 error: option `mode2' is incompatible with --mode1
Subcommand-related error messages should be consistent with these, and use the "error:" prefix as well. Unfortunately, both usage_msg_opt() and usage_msg_optf() use the "fatal:" prefix instead, so I will not use those functions anywhere in this patch series.
Show 5 quoted lines
> > +test_expect_success 'NO_INTERNAL_HELP works for -h' ' > > + test_expect_code 129 test-tool parse-options-flags --no-internal-help cmd -h 2>err && > > + cat err && > > Stray "cat", presumably in error..
Leftover debugging :(