X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=test-parse-options.c;h=61d2c39814529bd0264e4c9e40241131d51d819c;hb=18e143487ddb5b32b2f6003972d2115bb4ac460f;hp=277cfe4d6dceb5ebe2ce9f141b6eb21a4dc37912;hpb=02273fdbd07ddaa13a232db0ae63a720c4a013f0;p=git.git diff --git a/test-parse-options.c b/test-parse-options.c index 277cfe4d6..61d2c3981 100644 --- a/test-parse-options.c +++ b/test-parse-options.c @@ -3,8 +3,22 @@ static int boolean = 0; static int integer = 0; +static unsigned long timestamp; +static int abbrev = 7; +static int verbose = 0, dry_run = 0, quiet = 0; static char *string = NULL; +int length_callback(const struct option *opt, const char *arg, int unset) +{ + printf("Callback: \"%s\", %d\n", + (arg ? arg : "not set"), unset); + if (unset) + return 1; /* do not support unset */ + + *(int *)opt->value = strlen(arg); + return 0; +} + int main(int argc, const char **argv) { const char *usage[] = { @@ -13,11 +27,29 @@ int main(int argc, const char **argv) }; struct option options[] = { OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"), + OPT_BIT('4', "or4", &boolean, + "bitwise-or boolean with ...0100", 4), + OPT_GROUP(""), OPT_INTEGER('i', "integer", &integer, "get a integer"), OPT_INTEGER('j', NULL, &integer, "get a integer, too"), - OPT_GROUP("string options"), + OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23), + OPT_DATE('t', NULL, ×tamp, "get timestamp of