summaryrefslogtreecommitdiff
path: root/parse-options.h
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2009-05-23 01:38:32 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-05-23 01:38:32 -0700
commit104d3794481c83f8db00ccf85134fc55c76852f9 (patch)
treeddd0c863652be1ecade06d66bca1e8eb5fb37409 /parse-options.h
parentMerge branch 'fl/git-pm' (diff)
parentgrep: make callback functions static (diff)
downloadtgif-104d3794481c83f8db00ccf85134fc55c76852f9.tar.xz
Merge branch 'rs/grep-parseopt'
* rs/grep-parseopt: grep: make callback functions static grep: use parseopt grep: remove global variable builtin_grep parseopt: add PARSE_OPT_NODASH parseopt: add OPT_NUMBER_CALLBACK parseopt: add OPT_NEGBIT
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/parse-options.h b/parse-options.h
index b54eec128b..919b9b441f 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -6,8 +6,10 @@ enum parse_opt_type {
OPTION_END,
OPTION_ARGUMENT,
OPTION_GROUP,
+ OPTION_NUMBER,
/* options with no arguments */
OPTION_BIT,
+ OPTION_NEGBIT,
OPTION_BOOLEAN, /* _INCR would have been a better name */
OPTION_SET_INT,
OPTION_SET_PTR,
@@ -31,6 +33,7 @@ enum parse_opt_option_flags {
PARSE_OPT_NONEG = 4,
PARSE_OPT_HIDDEN = 8,
PARSE_OPT_LASTARG_DEFAULT = 16,
+ PARSE_OPT_NODASH = 32,
};
struct option;
@@ -64,8 +67,11 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
* PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs)
* PARSE_OPT_NOARG: says that this option takes no argument, for CALLBACKs
* PARSE_OPT_NONEG: says that this option cannot be negated
- * PARSE_OPT_HIDDEN this option is skipped in the default usage, showed in
- * the long one.
+ * PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
+ * shown only in the full usage.
+ * PARSE_OPT_LASTARG_DEFAULT: if no argument is given, the default value
+ * is used.
+ * PARSE_OPT_NODASH: this option doesn't start with a dash.
*
* `callback`::
* pointer to the callback to use for OPTION_CALLBACK.
@@ -93,6 +99,7 @@ struct option {
#define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, (h) }
#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }
#define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), 0, NULL, (b) }
+#define OPT_NEGBIT(s, l, v, h, b) { OPTION_NEGBIT, (s), (l), (v), NULL, (h), 0, NULL, (b) }
#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }
#define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) }
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }
@@ -103,6 +110,9 @@ struct option {
parse_opt_approxidate_cb }
#define OPT_CALLBACK(s, l, v, a, h, f) \
{ OPTION_CALLBACK, (s), (l), (v), (a), (h), 0, (f) }
+#define OPT_NUMBER_CALLBACK(v, h, f) \
+ { OPTION_NUMBER, 0, NULL, (v), NULL, (h), \
+ PARSE_OPT_NOARG | PARSE_OPT_NONEG, (f) }
/* parse_options() will filter out the processed options and leave the
* non-option arguments in argv[].