parseopt: make usage optional
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Sun, 8 Mar 2009 18:16:58 +0000 (19:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 8 Mar 2009 20:36:41 +0000 (13:36 -0700)
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 <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
index 8b21dea72e12416c806ae636e8a6f20f31ab9af8..51e804b3bea3dab71e1df7b9c7db3635025b538e 100644 (file)
@@ -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++);