Skip to content

Commit 49b6180

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b92891f commit 49b6180

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

parse-options.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ int parse_options(int argc, const char **argv, const struct option *options,
364364
int usage_with_options_internal(const char * const *usagestr,
365365
const struct option *opts, int full)
366366
{
367+
if (!usagestr)
368+
return PARSE_OPT_HELP;
369+
367370
fprintf(stderr, "usage: %s\n", *usagestr++);
368371
while (*usagestr && **usagestr)
369372
fprintf(stderr, " or: %s\n", *usagestr++);

0 commit comments

Comments
 (0)