mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[common] validate all options including defaults
This commit is contained in:
parent
b5975e0f05
commit
32d5f1db85
@ -197,20 +197,26 @@ bool option_parse(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(arg);
|
free(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate the option values
|
||||||
|
bool ok = true;
|
||||||
|
for(int i = 0; i < state.oCount; ++i)
|
||||||
|
{
|
||||||
|
struct Option * o = &state.options[i];
|
||||||
if (o->validator)
|
if (o->validator)
|
||||||
if (!o->validator(&o->value))
|
if (!o->validator(&o->value))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Invalid value provided to option: %s", argv[a]);
|
DEBUG_ERROR("Invalid value provided to option %s:%s", o->module, o->name);
|
||||||
|
|
||||||
if (o->printHelp)
|
if (o->printHelp)
|
||||||
o->printHelp();
|
o->printHelp();
|
||||||
|
|
||||||
return false;
|
ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void option_print()
|
void option_print()
|
||||||
|
Loading…
Reference in New Issue
Block a user