summaryrefslogtreecommitdiff
path: root/parse-options.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-09-04 12:37:52 -0700
committerJunio C Hamano <gitster@pobox.com>2013-09-04 12:37:52 -0700
commit366b80bf0a84b607115bd4ffcd8e5ebfc7338442 (patch)
tree8dace2d8aa41e2eb4f584529e1f3588d83b9bb3e /parse-options.h
parent5fb0e0868c25d4be66ead46992c393ed5f91c2d1 (diff)
parente6b722db099f435f21ce72b18f0d61dc3c778f1f (diff)
downloadgit-366b80bf0a84b607115bd4ffcd8e5ebfc7338442.tar.gz
Merge branch 'jc/parseopt-command-modes'
Many commands use --dashed-option as a operation mode selector (e.g. "git tag --delete") that the user can use at most one (e.g. "git tag --delete --verify" is a nonsense) and you cannot negate (e.g. "git tag --no-delete" is a nonsense). Make it easier for users of parse_options() to enforce these restrictions. * jc/parseopt-command-modes: tag: use OPT_CMDMODE parse-options: add OPT_CMDMODE()
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/parse-options.h b/parse-options.h
index 9b94596e4a..f37fc88143 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -13,6 +13,7 @@ enum parse_opt_type {
OPTION_COUNTUP,
OPTION_SET_INT,
OPTION_SET_PTR,
+ OPTION_CMDMODE,
/* options with arguments (usually) */
OPTION_STRING,
OPTION_INTEGER,
@@ -130,6 +131,8 @@ struct option {
#define OPT_BOOL(s, l, v, h) OPT_SET_INT(s, l, v, h, 1)
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, \
(h), PARSE_OPT_NOARG, NULL, (p) }
+#define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \
+ (h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) }
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) }
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
#define OPT_STRING_LIST(s, l, v, a, h) \