ArgPositional
Description
Register a positional argument. Slot order on the command line matches registration order. Always required.
name is both the help-text label and the metavar shown in usage output (rendered as <NAME>). It is not parsed for -- prefixes – positionals never start with -.
Usage example (from documentation)
const char *hostname = NULL;
ArgPositional(&p, "hostname", &hostname, "name to resolve");Usage example (Cross-references)
Usage examples (Cross-references)
- In
ArgParse.c:181:
const char *src = NULL;
const char *dst = NULL;
ArgPositional(&p, "source", &src, "from");
ArgPositional(&p, "dest", &dst, "to");- In
ArgParse.c:182:
const char *dst = NULL;
ArgPositional(&p, "source", &src, "from");
ArgPositional(&p, "dest", &dst, "to");
char *argv[] = {(char *)"cp", (char *)"a.txt", (char *)"b.txt"};- In
ArgParse.c:201:
const char *dst = NULL;
bool verbose = false;
ArgPositional(&p, "source", &src, "from");
ArgPositional(&p, "dest", &dst, "to");
ArgFlag(&p, "-v", "--verbose", &verbose, "v");- In
ArgParse.c:202:
bool verbose = false;
ArgPositional(&p, "source", &src, "from");
ArgPositional(&p, "dest", &dst, "to");
ArgFlag(&p, "-v", "--verbose", &verbose, "v");- In
ArgParse.c:315:
const char *src = NULL;
const char *dst = NULL;
ArgPositional(&p, "source", &src, "");
ArgPositional(&p, "dest", &dst, "");- In
ArgParse.c:316:
const char *dst = NULL;
ArgPositional(&p, "source", &src, "");
ArgPositional(&p, "dest", &dst, "");
char *argv[] = {(char *)"cp", (char *)"a.txt"};- In
ArgParse.c:384:
const char *x = NULL;
ArgPositional(&p, "x", &x, "");
char *argv[] = {(char *)"prog", (char *)"first", (char *)"extra"};- In
ArgParse.c:405:
const char *file = NULL;
ArgPositional(&p, "file", &file, "input file");
// "--unusual-name" would normally be parsed as an option; "--"
- In
ArgParse.c:440:
}
if (role == ARG_ROLE_POSITIONAL && !long_name) {
LOG_FATAL("arg_register: ArgPositional needs a non-NULL name");
}
if (role != ARG_ROLE_POSITIONAL && !short_name && !long_name) {- In
Resolve.c:24:
ArgParse ap = ArgParseInit("resolve", "look up a hostname via /etc/hosts and DNS");
ArgPositional(&ap, "hostname", &hostname, "name to resolve");
ArgRun rc = ArgParseRun(&ap, argc, argv);
Last updated on