Skip to content

Commit

Permalink
parseopt: make usage optional
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Mar 8, 2009
1 parent b92891f commit 49b6180
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++);
Expand Down

0 comments on commit 49b6180

Please sign in to comment.