X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=test-parse-options.c;h=61d2c39814529bd0264e4c9e40241131d51d819c;hb=49129d3731a6d74ad403ecdffc0e7940a597bc65;hp=4d3e2ec39e33f6301cc6df162dab7de9dbb2ea80;hpb=761e8566cb072047e836f1d7f50d3c0f67d7eb00;p=git.git diff --git a/test-parse-options.c b/test-parse-options.c index 4d3e2ec39..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,12 +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