X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=test-parse-options.c;h=2a79e729a4018ddb2da9ff633f4bf3b102fa8f88;hb=78e996451b5aa5b38318aa613e1c713434c61dbb;hp=4d3e2ec39e33f6301cc6df162dab7de9dbb2ea80;hpb=f81117b84d2c99a29acf06c6522aad54defbc760;p=git.git diff --git a/test-parse-options.c b/test-parse-options.c index 4d3e2ec39..2a79e729a 100644 --- a/test-parse-options.c +++ b/test-parse-options.c @@ -2,9 +2,22 @@ #include "parse-options.h" static int boolean = 0; -static int integer = 0; +static unsigned long integer = 0; +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 */ + + *(unsigned long *)opt->value = strlen(arg); + return 0; +} + int main(int argc, const char **argv) { const char *usage[] = { @@ -13,12 +26,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, &integer, "get timestamp of