Thread (79 messages) 79 messages, 3 authors, 2022-09-05

Re: [PATCH v2 04/20] t0040-parse-options: test parse_options() with various 'parse_opt_flags'

From: SZEDER Gábor <hidden>
Date: 2022-08-20 11:14:29

On Fri, Aug 19, 2022 at 07:23:44PM +0200, Ævar Arnfjörð Bjarmason wrote:
quoted
+		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.

quoted
+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 :(
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help