construct: Add STRINGS program options type support.
This commit is contained in:
parent
0b2152a136
commit
a2f55eeab8
|
@ -99,6 +99,19 @@ parseargs(int *argc, char * const **argv, struct lgetopt *opts)
|
||||||
(*argc)--;
|
(*argc)--;
|
||||||
(*argv)++;
|
(*argv)++;
|
||||||
break;
|
break;
|
||||||
|
case argtype::STRINGS:
|
||||||
|
if(*argc < 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"error: option '%c%s' requires an argument\n",
|
||||||
|
OPTCHAR, opts[i].opt);
|
||||||
|
usage(progname, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
((std::vector<std::string> *)opts[i].argloc)->emplace_back((*argv)[1]);
|
||||||
|
(*argc)--;
|
||||||
|
(*argv)++;
|
||||||
|
break;
|
||||||
|
|
||||||
case argtype::USAGE:
|
case argtype::USAGE:
|
||||||
usage(progname, opts);
|
usage(progname, opts);
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct lgetopt
|
||||||
const char *opt; /* name of the argument */
|
const char *opt; /* name of the argument */
|
||||||
void *argloc; /* where we store the argument to it (-option argument) */
|
void *argloc; /* where we store the argument to it (-option argument) */
|
||||||
enum
|
enum
|
||||||
{ INTEGER, YESNO, STRING, USAGE, ENDEBUG, BOOL }
|
{ INTEGER, YESNO, STRING, STRINGS, USAGE, ENDEBUG, BOOL }
|
||||||
argtype;
|
argtype;
|
||||||
const char *desc; /* description of the argument, usage for printing help */
|
const char *desc; /* description of the argument, usage for printing help */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue