X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=parse-options.h;h=2e811dc7da8e6adc7ebce1a9929e8c345424fe4a;hb=bd193f46b70fd3f8a55e2a8dcbb1fb2b4eec13d6;hp=59e0b524bdcbe1c061f49b8e5f3c6365a9f2eba4;hpb=79cfe0c5c4920bf68da548ad0d5bcdb425ce8d5f;p=git.git diff --git a/parse-options.h b/parse-options.h index 59e0b524b..2e811dc7d 100644 --- a/parse-options.h +++ b/parse-options.h @@ -10,7 +10,7 @@ enum parse_opt_type { /* options with no arguments */ OPTION_BIT, OPTION_NEGBIT, - OPTION_BOOLEAN, /* _INCR would have been a better name */ + OPTION_COUNTUP, OPTION_SET_INT, OPTION_SET_PTR, /* options with arguments (usually) */ @@ -21,6 +21,9 @@ enum parse_opt_type { OPTION_FILENAME }; +/* Deprecated synonym */ +#define OPTION_BOOLEAN OPTION_COUNTUP + enum parse_opt_flags { PARSE_OPT_KEEP_DASHDASH = 1, PARSE_OPT_STOP_AT_NON_OPTION = 2, @@ -122,10 +125,11 @@ struct option { 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, \ +#define OPT_COUNTUP(s, l, v, h) { OPTION_COUNTUP, (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_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_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), "n", (h) } @@ -149,6 +153,13 @@ struct option { { OPTION_CALLBACK, (s), (l), (v), "when", (h), PARSE_OPT_OPTARG, \ parse_opt_color_flag_cb, (intptr_t)"always" } +#define OPT_NOOP_NOARG(s, l) \ + { OPTION_CALLBACK, (s), (l), NULL, NULL, \ + "no-op (backward compatibility)", \ + PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, parse_opt_noop_cb } + +/* Deprecated synonym */ +#define OPT_BOOLEAN OPT_COUNTUP /* parse_options() will filter out the processed options and leave the * non-option arguments in argv[]. @@ -210,6 +221,7 @@ extern int parse_opt_verbosity_cb(const struct option *, const char *, int); extern int parse_opt_with_commit(const struct option *, const char *, int); extern int parse_opt_tertiary(const struct option *, const char *, int); extern int parse_opt_string_list(const struct option *, const char *, int); +extern int parse_opt_noop_cb(const struct option *, const char *, int); #define OPT__VERBOSE(var, h) OPT_BOOLEAN('v', "verbose", (var), (h)) #define OPT__QUIET(var, h) OPT_BOOLEAN('q', "quiet", (var), (h))