ArgCount
Description
Register a repeat counter. No value consumed; the target is incremented per occurrence. -vvv counts as three. Target must be one of the unsigned integer pointer types.
Usage example (from documentation)
u32 verbose = 0;
ArgCount(&p, "-v", "--verbose", &verbose, "verbose logging (repeatable)");Success
Appends an ARG_ROLE_COUNT spec; the unsigned target is incremented once per occurrence at parse time.
Failure
LOG_FATAL if parser is NULL, if target is not one of u8 * / u16 * / u32 * / u64 *, or if both short_ and long_ are NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ArgParse.c:436:
if (role == ARG_ROLE_COUNT && target.kind != ARG_KIND_U8 && target.kind != ARG_KIND_U16 &&
target.kind != ARG_KIND_U32 && target.kind != ARG_KIND_U64) {
LOG_FATAL("arg_register: ArgCount '{}' requires a u8/u16/u32/u64* target", long_name ? long_name : short_name);
}
if (role == ARG_ROLE_POSITIONAL && !long_name) {- In
ArgParse.c:134:
u32 verbose = 0;
ArgCount(&p, "-v", "--verbose", &verbose, "v");
char *argv[] = {(char *)"prog", (char *)"-v", (char *)"-v", (char *)"-v"};- In
ArgParse.c:150:
u32 verbose = 0;
ArgCount(&p, "-v", "--verbose", &verbose, "v");
char *argv[] = {(char *)"prog", (char *)"-vvv"};- In
ArgParse.c:430:
ArgParse p = ArgParseInit("prog", NULL, &a);
u8 n = 0;
ArgCount(&p, "-v", "--verbose", &n, "v");
char *argv[] = {(char *)"prog", (char *)"-v", (char *)"-v"};
ArgRun rc = ArgParseRun(&p, 3, argv);- In
ArgParse.c:443:
ArgParse p = ArgParseInit("prog", NULL, &a);
u16 n = 0;
ArgCount(&p, "-v", "--verbose", &n, "v");
char *argv[] = {(char *)"prog", (char *)"-vvvv"};
ArgRun rc = ArgParseRun(&p, 2, argv);- In
ArgParse.c:456:
ArgParse p = ArgParseInit("prog", NULL, &a);
u64 n = 0;
ArgCount(&p, "-v", "--verbose", &n, "v");
char *argv[] = {(char *)"prog", (char *)"-v", (char *)"-v", (char *)"-v"};
ArgRun rc = ArgParseRun(&p, 4, argv);- In
ArgParse.c:502:
ArgParse p = ArgParseInit("prog", NULL, &a);
u32 n = 0;
ArgCount(&p, "-v", "--verbose", &n, "v");
char *argv[] = {(char *)"prog", (char *)"--verbose=3"};
ArgRun rc = ArgParseRun(&p, 2, argv);- In
ArgParse.c:1580:
u32 verbose = 0;
ArgCount(&p, "-v", "--verbose", &verbose, "v");
// "-vx": -v is a valid count (so the bundle is attempted), x is unknown.
- In
ArgParse.c:1601:
u32 verbose = 0;
ArgCount(&p, "-v", "--verbose", &verbose, "v");
char *argv[] = {(char *)"prog", (char *)"-vv"};- In
ArgParse.c:1668:
u32 verbose = 0;
Zstr listen = NULL;
ArgCount(&p, "-v", "--verbose", &verbose, "v");
ArgRequired(&p, "-l", "--listen", &listen, "host:port");
Last updated on