parse-options: allow -h as a short option

Let callers provide their own handler for the short option -h even
without the flag PARSE_OPT_NO_INTERNAL_HELP, but call the internal
handler (showing usage information) if that is the only parameter.
Implement the first part by checking for -h only if parse_short_opt()
can't find it and returns -2.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
This commit is contained in:
René Scharfe
2015-11-17 11:25:38 +01:00
committed by Jeff King
parent d3d1f8c46f
commit 5ad0d3d526
2 changed files with 11 additions and 6 deletions

View File

@ -199,7 +199,7 @@ enum {
struct parse_opt_ctx_t {
const char **argv;
const char **out;
int argc, cpidx;
int argc, cpidx, total;
const char *opt;
int flags;
const char *prefix;