fetching submodules: respect `submodule.fetchJobs` config option
[gitweb.git] / test-parse-options.c
index 91a5701657556e07b4f4daafa947346d3b197cd1..2c8c8f18edb46378b39c170b4ae6f7250ec631f5 100644 (file)
@@ -4,6 +4,7 @@
 
 static int boolean = 0;
 static int integer = 0;
+static unsigned long magnitude = 0;
 static unsigned long timestamp;
 static int abbrev = 7;
 static int verbose = 0, dry_run = 0, quiet = 0;
@@ -29,7 +30,7 @@ static int number_callback(const struct option *opt, const char *arg, int unset)
        return 0;
 }
 
-int main(int argc, const char **argv)
+int main(int argc, char **argv)
 {
        const char *prefix = "prefix/";
        const char *usage[] = {
@@ -37,13 +38,18 @@ int main(int argc, const char **argv)
                NULL
        };
        struct option options[] = {
-               OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"),
+               OPT_BOOL(0, "yes", &boolean, "get a boolean"),
+               OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"),
+               { OPTION_SET_INT, 'B', "no-fear", &boolean, NULL,
+                 "be brave", PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },
+               OPT_COUNTUP('b', "boolean", &boolean, "increment by one"),
                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"),
+               OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"),
                OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
                OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
                OPT_CALLBACK('L', "length", &integer, "str",
@@ -54,18 +60,17 @@ int main(int argc, const char **argv)
                OPT_STRING(0, "string2", &string, "str", "get another string"),
                OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"),
                OPT_STRING('o', NULL, &string, "str", "get another string"),
-               OPT_SET_PTR(0, "default-string", &string,
-                       "set string to default", (unsigned long)"default"),
+               OPT_NOOP_NOARG(0, "obsolete"),
                OPT_STRING_LIST(0, "list", &list, "str", "add str to list"),
                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",
+               { OPTION_COUNTUP, '+', NULL, &boolean, NULL, "same as -b",
                  PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH },
-               { OPTION_BOOLEAN, 0, "ambiguous", &ambiguous, NULL,
+               { OPTION_COUNTUP, 0, "ambiguous", &ambiguous, NULL,
                  "positive ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG },
-               { OPTION_BOOLEAN, 0, "no-ambiguous", &ambiguous, NULL,
+               { OPTION_COUNTUP, 0, "no-ambiguous", &ambiguous, NULL,
                  "negative ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG },
                OPT_GROUP("Standard options"),
                OPT__ABBREV(&abbrev),
@@ -76,10 +81,11 @@ int main(int argc, const char **argv)
        };
        int i;
 
-       argc = parse_options(argc, argv, prefix, options, usage, 0);
+       argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
 
        printf("boolean: %d\n", boolean);
-       printf("integer: %u\n", integer);
+       printf("integer: %d\n", integer);
+       printf("magnitude: %lu\n", magnitude);
        printf("timestamp: %lu\n", timestamp);
        printf("string: %s\n", string ? string : "(not set)");
        printf("abbrev: %d\n", abbrev);