diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-05-23 01:38:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-05-23 01:38:32 -0700 |
commit | 104d3794481c83f8db00ccf85134fc55c76852f9 (patch) | |
tree | ddd0c863652be1ecade06d66bca1e8eb5fb37409 /test-parse-options.c | |
parent | Merge branch 'fl/git-pm' (diff) | |
parent | grep: make callback functions static (diff) | |
download | tgif-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 'test-parse-options.c')
-rw-r--r-- | test-parse-options.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test-parse-options.c b/test-parse-options.c index 61d2c39814..e0669dcb41 100644 --- a/test-parse-options.c +++ b/test-parse-options.c @@ -19,6 +19,12 @@ int length_callback(const struct option *opt, const char *arg, int unset) return 0; } +int number_callback(const struct option *opt, const char *arg, int unset) +{ + *(int *)opt->value = strtol(arg, NULL, 10); + return 0; +} + int main(int argc, const char **argv) { const char *usage[] = { @@ -29,6 +35,7 @@ int main(int argc, const char **argv) OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"), OPT_BIT('4', "or4", &boolean, "bitwise-or boolean with ...0100", 4), + OPT_NEGBIT(0, "neg-or4", &boolean, "same as --no-or4", 4), OPT_GROUP(""), OPT_INTEGER('i', "integer", &integer, "get a integer"), OPT_INTEGER('j', NULL, &integer, "get a integer, too"), @@ -45,6 +52,10 @@ int main(int argc, const char **argv) "set string to default", (unsigned long)"default"), OPT_GROUP("Magic arguments"), OPT_ARGUMENT("quux", "means --quux"), + OPT_NUMBER_CALLBACK(&integer, "set integer to NUM", + number_callback), + { OPTION_BOOLEAN, '+', NULL, &boolean, NULL, "same as -b", + PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH }, OPT_GROUP("Standard options"), OPT__ABBREV(&abbrev), OPT__VERBOSE(&verbose), |