cam: Separate options valid() and empty()
An empty option list is not necessarily an error. Add a new empty() function to test the option list for emptiness, and modify the valid() function to only notify parsing errors. As a side effect this allows accessing partially parsed options, which may be useful in the future. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
3f906920e4
commit
f8386836df
3 changed files with 24 additions and 22 deletions
|
@ -67,9 +67,12 @@ static int parseOptions(int argc, char *argv[])
|
|||
parser.addOption(OptList, OptionNone, "List all cameras", "list");
|
||||
|
||||
options = parser.parse(argc, argv);
|
||||
if (!options.valid() || options.isSet(OptHelp)) {
|
||||
if (!options.valid())
|
||||
return -EINVAL;
|
||||
|
||||
if (options.empty() || options.isSet(OptHelp)) {
|
||||
parser.usage();
|
||||
return !options.valid() ? -EINVAL : -EINTR;
|
||||
return options.empty() ? -EINVAL : -EINTR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue