From 49b6180252000e37ec47ccb4156240ed625949ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 8 Mar 2009 19:16:58 +0100 Subject: parseopt: make usage optional Allow usagestr to be NULL and don't display any help screen in this case. This is useful to implement incremental parsers. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano diff --git a/parse-options.c b/parse-options.c index 8b21dea..51e804b 100644 --- a/parse-options.c +++ b/parse-options.c @@ -364,6 +364,9 @@ int parse_options(int argc, const char **argv, const struct option *options, int usage_with_options_internal(const char * const *usagestr, const struct option *opts, int full) { + if (!usagestr) + return PARSE_OPT_HELP; + fprintf(stderr, "usage: %s\n", *usagestr++); while (*usagestr && **usagestr) fprintf(stderr, " or: %s\n", *usagestr++); -- cgit v0.10.2-6-g49f6