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:
+6
-4
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user