Commit 4ed0f2c5 authored by Michel Arruat's avatar Michel Arruat Committed by Adam Wujek

liblinux/extest library Support named arguments for commands

some complex commands where arguments are optional need named arguments
to identify which ones are provided. The supported syntax is basic,
like: cmdname -a value1 -b value2
Signed-off-by: Michel Arruat's avatarMichel Arruat <michel.arruat@cern.ch>
parent 3c9585fc
......@@ -196,6 +196,22 @@ static int get_atoms(char *input, struct atom *atoms)
if (*buf == '-') {
char *c = buf + 1;
if (atomhash[(int)*c] == Alpha) {
/*
* -[a--z]: it's an argument for the
* command like : cmd -x val1 -y val2
* Note: Argument name is limited to a
* single letter
*/
atoms[cnt].pos = (unsigned int)(buf - input);
atoms[cnt].text[0] = *buf++;
atoms[cnt].text[1] = *buf++;
atoms[cnt].text[2] = '\0';
atoms[cnt].type = String;
cnt++;
break;
}
if (*c && isdigit(*c)) {
atype = Numeric;
goto reeval;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment