X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=parse-options.h;h=bc317e7512af7a1cc86641a651ae5415d28e71c4;hb=65360346309a550185363ef5b846a1202175a4e6;hp=72027f3c66ef7df0fe18002887a03e24af571ca0;hpb=7e7bbcb4b35cbb4bbb5e65cf057c84b16dbd3d39;p=git.git diff --git a/parse-options.h b/parse-options.h index 72027f3c6..bc317e751 100644 --- a/parse-options.h +++ b/parse-options.h @@ -20,6 +20,7 @@ enum parse_opt_type { enum parse_opt_flags { PARSE_OPT_KEEP_DASHDASH = 1, PARSE_OPT_STOP_AT_NON_OPTION = 2, + PARSE_OPT_KEEP_ARGV0 = 4, }; enum parse_opt_option_flags { @@ -27,6 +28,7 @@ enum parse_opt_option_flags { PARSE_OPT_NOARG = 2, PARSE_OPT_NONEG = 4, PARSE_OPT_HIDDEN = 8, + PARSE_OPT_LASTARG_DEFAULT = 16, }; struct option; @@ -113,6 +115,17 @@ extern NORETURN void usage_with_options(const char * const *usagestr, /*----- incremantal advanced APIs -----*/ +enum { + PARSE_OPT_HELP = -1, + PARSE_OPT_DONE, + PARSE_OPT_UNKNOWN, +}; + +/* + * It's okay for the caller to consume argv/argc in the usual way. + * Other fields of that structure are private to parse-options and should not + * be modified in any way. + */ struct parse_opt_ctx_t { const char **argv; const char **out; @@ -121,9 +134,16 @@ struct parse_opt_ctx_t { int flags; }; +extern int parse_options_usage(const char * const *usagestr, + const struct option *opts); + extern void parse_options_start(struct parse_opt_ctx_t *ctx, int argc, const char **argv, int flags); +extern int parse_options_step(struct parse_opt_ctx_t *ctx, + const struct option *options, + const char * const usagestr[]); + extern int parse_options_end(struct parse_opt_ctx_t *ctx);