summaryrefslogtreecommitdiff
path: root/parse-options.h
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-09-21 22:40:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-23 17:30:43 (GMT)
commitd35d03cf93ef0dba3e975c78fce73db91d52ba42 (patch)
treed73e8950e435eeb64934855c8454d3d1754918e8 /parse-options.h
parent0a5940fbe7e453652266e765509a576e4df333c7 (diff)
downloadgit-d35d03cf93ef0dba3e975c78fce73db91d52ba42.zip
git-d35d03cf93ef0dba3e975c78fce73db91d52ba42.tar.gz
git-d35d03cf93ef0dba3e975c78fce73db91d52ba42.tar.bz2
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>
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/parse-options.h b/parse-options.h
index a845a9d..0e9271d 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -169,8 +169,10 @@ struct option {
#define OPT_BOOL(s, l, v, h) OPT_BOOL_F(s, l, v, h, 0)
#define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \
(h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}
-#define OPT_CMDMODE(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, \
- (h), PARSE_OPT_CMDMODE|PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) }
+#define OPT_CMDMODE_F(s, l, v, h, i, f) { OPTION_SET_INT, (s), (l), (v), NULL, \
+ (h), PARSE_OPT_CMDMODE|PARSE_OPT_NOARG|PARSE_OPT_NONEG | (f), NULL, (i) }
+#define OPT_CMDMODE(s, l, v, h, i) OPT_CMDMODE_F(s, l, v, h, i, 0)
+
#define OPT_INTEGER(s, l, v, h) OPT_INTEGER_F(s, l, v, h, 0)
#define OPT_MAGNITUDE(s, l, v, h) { OPTION_MAGNITUDE, (s), (l), (v), \
N_("n"), (h), PARSE_OPT_NONEG }