]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse-options: add parse_opt_unknown_cb()
authorMichael Haggerty <mhagger@alum.mit.edu>
Mon, 5 Sep 2016 09:44:52 +0000 (11:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Sep 2016 17:25:11 +0000 (10:25 -0700)
Add a new callback function, parse_opt_unknown_cb(), which returns -2 to
indicate that the corresponding option is unknown. This can be used to
add "-h" documentation for an option that will be handled externally to
parse_options().

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options-cb.c
parse-options.h

index ba5acf3111d809a3c77314fb2c0852854620cfae..9f2f9b3df6af63346f2ee87aa0c4b5133044ef22 100644 (file)
@@ -153,6 +153,18 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
+/**
+ * Report that the option is unknown, so that other code can handle
+ * it. This can be used as a callback together with
+ * OPTION_LOWLEVEL_CALLBACK to allow an option to be documented in the
+ * "-h" output even if it's not being handled directly by
+ * parse_options().
+ */
+int parse_opt_unknown_cb(const struct option *opt, const char *arg, int unset)
+{
+       return -2;
+}
+
 /**
  * Recreates the command-line option in the strbuf.
  */
index ea4af92a5110554c450665e08fce3a97310e5640..b2cc6a5574ddb28b9737c7a5f8841dc55a57a450 100644 (file)
@@ -228,6 +228,7 @@ extern int parse_opt_commits(const struct option *, const char *, int);
 extern int parse_opt_tertiary(const struct option *, const char *, int);
 extern int parse_opt_string_list(const struct option *, const char *, int);
 extern int parse_opt_noop_cb(const struct option *, const char *, int);
+extern int parse_opt_unknown_cb(const struct option *, const char *, int);
 extern int parse_opt_passthru(const struct option *, const char *, int);
 extern int parse_opt_passthru_argv(const struct option *, const char *, int);