From 6acec0380bfcd5e3f91c9100bf4d415db8f7acfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 28 Sep 2011 19:44:30 +0200 Subject: parseopt: add OPT_NOOP_NOARG Add OPT_NOOP_NOARG, a helper macro to define deprecated options in a standard way. The help text is taken from the no-op option -r of git revert. The callback could be made to emit a (conditional?) warning later. And we could also add OPT_NOOP (requiring an argument) etc. as needed. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- parse-options.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'parse-options.h') diff --git a/parse-options.h b/parse-options.h index 22c0273052..2e811dc7da 100644 --- a/parse-options.h +++ b/parse-options.h @@ -153,6 +153,11 @@ 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 @@ -216,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)) -- cgit v1.2.1