test-parse-options.con commit Fix random sha1 in error message in http-fetch and http-push (a096bb1)
   1#include "cache.h"
   2#include "parse-options.h"
   3
   4static int boolean = 0;
   5static int integer = 0;
   6static char *string = NULL;
   7
   8int main(int argc, const char **argv)
   9{
  10        const char *usage[] = {
  11                "test-parse-options <options>",
  12                NULL
  13        };
  14        struct option options[] = {
  15                OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"),
  16                OPT_INTEGER('i', "integer", &integer, "get a integer"),
  17                OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
  18                OPT_GROUP("string options"),
  19                OPT_STRING('s', "string", &string, "string", "get a string"),
  20                OPT_STRING(0, "string2", &string, "str", "get another string"),
  21                OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"),
  22                OPT_END(),
  23        };
  24        int i;
  25
  26        argc = parse_options(argc, argv, options, usage, 0);
  27
  28        printf("boolean: %d\n", boolean);
  29        printf("integer: %d\n", integer);
  30        printf("string: %s\n", string ? string : "(not set)");
  31
  32        for (i = 0; i < argc; i++)
  33                printf("arg %02d: %s\n", i, argv[i]);
  34
  35        return 0;
  36}