construct: Add STRINGS program options type support.

This commit is contained in:
Jason Volk 2020-04-24 16:39:51 -07:00
parent 0b2152a136
commit a2f55eeab8
2 changed files with 14 additions and 1 deletions

View File

@ -99,6 +99,19 @@ parseargs(int *argc, char * const **argv, struct lgetopt *opts)
(*argc)--;
(*argv)++;
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:
usage(progname, opts);

View File

@ -27,7 +27,7 @@ struct lgetopt
const char *opt; /* name of the argument */
void *argloc; /* where we store the argument to it (-option argument) */
enum
{ INTEGER, YESNO, STRING, USAGE, ENDEBUG, BOOL }
{ INTEGER, YESNO, STRING, STRINGS, USAGE, ENDEBUG, BOOL }
argtype;
const char *desc; /* description of the argument, usage for printing help */
};