]> git.ipfire.org Git - thirdparty/git.git/commit - parse-options.h
help: simplify by moving to OPT_CMDMODE()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 21 Sep 2021 22:40:36 +0000 (00:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Sep 2021 17:30:43 +0000 (10:30 -0700)
commitd35d03cf93ef0dba3e975c78fce73db91d52ba42
treed73e8950e435eeb64934855c8454d3d1754918e8
parent0a5940fbe7e453652266e765509a576e4df333c7
help: simplify by moving to OPT_CMDMODE()

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.

This is the first command with a hidden CMDMODE, so let's introduce a
OPT_CMDMODE_F() macro to go along with OPT_CMDMODE().

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
    $

But improving that is a general topic for parse-options.c improvement,
i.e. we should probably emit the full usage in that case.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/help.c
parse-options.h