summaryrefslogtreecommitdiff
path: root/parse-options.h
diff options
context:
space:
mode:
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/parse-options.h b/parse-options.h
index ae15342390..997ffbee80 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -3,8 +3,10 @@
#include "gettext.h"
+struct repository;
+
/**
- * Refer to Documentation/technical/api-parse-options.txt for the API doc.
+ * Refer to Documentation/technical/api-parse-options.adoc for the API doc.
*/
enum parse_opt_type {
@@ -73,7 +75,7 @@ typedef enum parse_opt_result parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
const char *arg, int unset);
typedef int parse_opt_subcommand_fn(int argc, const char **argv,
- const char *prefix);
+ const char *prefix, struct repository *repo);
/*
* `type`::
@@ -351,6 +353,18 @@ struct option {
.callback = parse_opt_noop_cb, \
}
+static char *parse_options_noop_ignored_value MAYBE_UNUSED;
+#define OPT_NOOP_ARG(s, l) { \
+ .type = OPTION_CALLBACK, \
+ .short_name = (s), \
+ .long_name = (l), \
+ .value = &parse_options_noop_ignored_value, \
+ .argh = "ignored", \
+ .help = N_("no-op (backward compatibility)"), \
+ .flags = PARSE_OPT_HIDDEN, \
+ .callback = parse_opt_noop_cb, \
+}
+
#define OPT_ALIAS(s, l, source_long_name) { \
.type = OPTION_ALIAS, \
.short_name = (s), \
@@ -388,6 +402,10 @@ int parse_options(int argc, const char **argv, const char *prefix,
NORETURN void usage_with_options(const char * const *usagestr,
const struct option *options);
+void show_usage_with_options_if_asked(int ac, const char **av,
+ const char * const *usage,
+ const struct option *options);
+
NORETURN void usage_msg_opt(const char *msg,
const char * const *usagestr,
const struct option *options);
@@ -418,6 +436,15 @@ static inline void die_for_incompatible_opt3(int opt1, const char *opt1_name,
0, "");
}
+static inline void die_for_incompatible_opt2(int opt1, const char *opt1_name,
+ int opt2, const char *opt2_name)
+{
+ die_for_incompatible_opt4(opt1, opt1_name,
+ opt2, opt2_name,
+ 0, "",
+ 0, "");
+}
+
/*
* Use these assertions for callbacks that expect to be called with NONEG and
* NOARG respectively, and do not otherwise handle the "unset" and "arg"