[PATCH/RFC] parse-options: allow to define hidden synonym options
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 19, 2007, 06:09 UTC
- Message-ID
- <7v4pfircka.fsf@gitster.siamese.dyndns.org>
By setting the help member to NULL, you can implement an option that is not shown in the "git-cmd -h" help output. This is useful to support backward compatible synonyms without cluttering the help text.
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- parse-options.c | 2 ++ parse-options.h | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/parse-options.c b/parse-options.c index d3e608a..1ee2c81 100644 --- a/parse-options.c +++ b/parse-options.c @@ -284,6 +284,8 @@ void usage_with_options(const char * const *usagestr, if (*opts->help) fprintf(stderr, "%s\n", opts->help); continue; + } else if (!opts->help) { + continue; } pos = fprintf(stderr, " "); diff --git a/parse-options.h b/parse-options.h index a8760ac..de249a0 100644 --- a/parse-options.h +++ b/parse-options.h @@ -49,7 +49,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset); * * `help`:: * the short help associated to what the option does. - * Must never be NULL (except for OPTION_END). + * option with this field set to NULL does not appear in the help listing. * OPTION_GROUP uses this pointer to store the group header. * * `flags`::
-- 1.5.3.6.1779.ga3ed