mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-13 04:27:55 +00:00
[common] validate all options including defaults
This commit is contained in:
parent
b5975e0f05
commit
32d5f1db85
1 changed files with 9 additions and 3 deletions
|
@ -197,20 +197,26 @@ bool option_parse(int argc, char * argv[])
|
|||
}
|
||||
|
||||
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(&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)
|
||||
o->printHelp();
|
||||
|
||||
return false;
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
void option_print()
|
||||
|
|
Loading…
Reference in a new issue