cam: options: Add option type handling to options parser
Extend the options parser with support for option types. All options must now specify the type of their argument, and the parser automatically parses the argument and handles errors internally. Available types are none, integer or string. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
6f3503981a
commit
c8c546fe99
3 changed files with 172 additions and 12 deletions
|
@ -37,10 +37,12 @@ static int parseOptions(int argc, char *argv[])
|
|||
{
|
||||
OptionsParser parser;
|
||||
|
||||
parser.addOption(OptCamera, "Specify which camera to operate on",
|
||||
"camera", ArgumentRequired, "camera");
|
||||
parser.addOption(OptHelp, "Display this help message", "help");
|
||||
parser.addOption(OptList, "List all cameras", "list");
|
||||
parser.addOption(OptCamera, OptionString,
|
||||
"Specify which camera to operate on", "camera",
|
||||
ArgumentRequired, "camera");
|
||||
parser.addOption(OptHelp, OptionNone, "Display this help message",
|
||||
"help");
|
||||
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
||||
|
||||
options = parser.parse(argc, argv);
|
||||
if (!options.valid())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue