I have this code:
parser.addOption(requiredValueOption);
parser.addOption(booleanOption);
if (!parser.parse(app->arguments())) {
qDebug() << parser.errorText();
parser.showHelp(1);
}
When I call it like this:
./app --required-value-option value
It works.
When I call it like this:
./app --required-value-option
I see an error message "missing value after...", which is expected
But when I call it like this:
./app --required-value-option --boolean-option
The string --boolean-option
is interpreted as a value for --required-value-option
!!! This is no what I expect. This should trigger an error.
How to correctly parse the options with required values using QCommandLineParser?
UPD: If you use some required values for options in your Qt applications - You can test it.
UPD2: Current behaviour for example: --no-gui boolean option and --output-file required file option. Run it as monkey:
app --output-file --no-gui
Wow! The application starts with gui and show "--no-gui file does not exist". Good job man!
UPD3: Ok. I want to interpret the registered options as options and not as values for previous options. Example: --no-gui can be valid filename, but since this is registered option, the parser shouldn't use it as value.