Re: [PATCH v3 6/9] help: simplify by moving to OPT_CMDMODE()
From: Junio C Hamano <hidden>
Date: 2021-09-23 18:05:23
Ævar Arnfjörð Bjarmason [off-list ref] writes:
As preceding commits have incrementally established all of the --all, --guides, --config and hidden --config-for-completion options are mutually exclusive. So let's use OPT_CMDMODE() to parse the command-line instead, and take advantage of its conflicting options detection.
Sounds quite logical.
I think this makes the usage information that we emit slightly worse,
e.g. before we'd emit:
$ git help --all --config
fatal: --config and --all cannot be combined
usage: git help [-a|--all] [--[no-]verbose]]
[[-i|--info] [-m|--man] [-w|--web]] [<command>]
or: git help [-g|--guides]
or: git help [-c|--config]
[...]
$
And now:
$ git help --all --config
error: option `config' is incompatible with --all
$We often hear that our error messages for command line options are unhelpful by being too broad, don't we? I think the new one would be much better by not scrolling away the most important part. Those who want to know about options other than --all and --config can issue "git help -h" after seeing that single line error, but not everybody has to do so.
But improving that is a general topic for parse-options.c improvement, i.e. we should probably emit the full usage in that case.
Yes, absolutely.