parse-options: simplify usage argh handling
Simplify the argh printing by simply calling usage_argh() if the option can take an argument. Update macros defined in parse-options.h to set the PARSE_OPT_NOARG flag. The only other user of custom non-argument taking options is git-apply (in this case OPTION_BOOLEAN for deprecated options). Update it to set the PARSE_OPT_NOARG flag. Thanks to Ren辿 Scharfe for the suggestion and starter patch. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Reviewd-by: René Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e3a0ca8784
commit
34aec9f573
@ -67,7 +67,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
|
||||
* `flags`::
|
||||
* mask of parse_opt_option_flags.
|
||||
* PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs)
|
||||
* PARSE_OPT_NOARG: says that this option takes no argument, for CALLBACKs
|
||||
* PARSE_OPT_NOARG: says that this option takes no argument
|
||||
* PARSE_OPT_NONEG: says that this option cannot be negated
|
||||
* PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
|
||||
* shown only in the full usage.
|
||||
@ -101,13 +101,19 @@ struct option {
|
||||
};
|
||||
|
||||
#define OPT_END() { OPTION_END }
|
||||
#define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, (h) }
|
||||
#define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, \
|
||||
(h), PARSE_OPT_NOARG}
|
||||
#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }
|
||||
#define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), 0, NULL, (b) }
|
||||
#define OPT_NEGBIT(s, l, v, h, b) { OPTION_NEGBIT, (s), (l), (v), NULL, (h), 0, NULL, (b) }
|
||||
#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }
|
||||
#define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) }
|
||||
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }
|
||||
#define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), \
|
||||
PARSE_OPT_NOARG, NULL, (b) }
|
||||
#define OPT_NEGBIT(s, l, v, h, b) { OPTION_NEGBIT, (s), (l), (v), NULL, \
|
||||
(h), PARSE_OPT_NOARG, NULL, (b) }
|
||||
#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, \
|
||||
(h), PARSE_OPT_NOARG }
|
||||
#define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, \
|
||||
(h), PARSE_OPT_NOARG, NULL, (i) }
|
||||
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, \
|
||||
(h), PARSE_OPT_NOARG, NULL, (p) }
|
||||
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), "n", (h) }
|
||||
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
|
||||
#define OPT_DATE(s, l, v, h) \
|
||||
|
Reference in New Issue
Block a user