@matheusbsbs / matheus-bagliano / commits / 49b6180252
Fork 0

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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Mar 8, 2009 at 19:16 UTC 49b6180252000e37ec47ccb4156240ed625949ed
1 file changed +3
parse-options.c
+3
@@ -364,6 +364,9 @@ int parse_options(int argc, const char **argv, const struct option *options,
364 int usage_with_options_internal(const char * const *usagestr,
365 const struct option *opts, int full)
366 {
367 + if (!usagestr)
368 + return PARSE_OPT_HELP;
369 +
370 fprintf(stderr, "usage: %s\n", *usagestr++);
371 while (*usagestr && **usagestr)
372 fprintf(stderr, " or: %s\n", *usagestr++);