I have a Poco (v1.9.4) based class
class PreprocessingApp : public Poco::Util::Application
with these 2 methods:
void PreprocessingApp::defineOptions(OptionSet& options)
{
Application::defineOptions(options);
options.addOption(
Option("proxy", "p", "Proxify connection")
.required(false)
.repeatable(false)
.argument("the value", false)
.callback(OptionCallback<PreprocessingApp>(this, &PreprocessingApp::handleBooleanOption))
);
options.addOption(
Option("test", "t", "Test something")
.required(true)
.repeatable(false)
.callback(OptionCallback<PreprocessingApp>(this, &PreprocessingApp::handleBooleanOption))
);
}
void PreprocessingApp::handleBooleanOption(const string& name, const string& value)
{
bool actualValue = value.empty() | value == "true" | value == "1";
config().setBool(name, actualValue);
}
As you can see, "proxy" is a boolean option. I added ".argument("the value", false)" to allow passing argument with this option, but flagged the "required" as false to make it optional.
That way I hoped to allow this functionality:
PreprocessingApp [-p [value]] -t [value]
Both variants should work:
PreprocessingApp -p -t
PreprocessingApp -p true -t
In reality, when debugging handleBooleanOption, the "value" is always empty "".
When switching required to true (.argument("the value", true)), the "value" is "-t" and next option processing is omitted.
Is there any solution to get it work as intended?