You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use an INI file to configure my app and cmd line arguments to overwrite some of it's properties.
Trying to figure out which options are set from the INI, by not passing any arguments from the cmd line, I realized that app.got_subcommnad(sApp) is always false.
Additionally, the ->required() flag that I set to some of the sub-commnads options is ignored at the INI level.
I temporarily fixed the issue by extending _parse_single_config to call ->increment_parsed() for the sub-commands, i.e.,
/// Fill in a single config option
bool _parse_single_config(const ConfigItem &item, size_t level = 0) {
if(level < item.parents.size()) {
try {
auto subcom = get_subcommand(item.parents.at(level));
//TODO tmp fix
subcom->increment_parsed();
return subcom->_parse_single_config(item, level + 1);
} catch(const OptionNotFound &) {
return false;
}
}
and appears to resolve my issues. I don't really have an overview of the arch to figure out whether there are side effects by doing so. Any suggestions?
The text was updated successfully, but these errors were encountered:
That seems like a bug, though also seems like from some of the other issues, some work needs to be done with the config to make the processing behave more like handling of command line arguments. Which would resolve this and a few other issues, and likely some others that haven't been expressed yet.
I haven't verified but you might also be able to use the count_all function to get a number of the arguments called within a subcommand, I think that should be non-zero even in the config file.
Update to this issue.
Digging into it the way it was designed by default the configuration file was intended to only update defaults. The command line overrides any arguments. The same is true for subcommands, so it was not intended to trigger subcommands so by default it would update the values but not increment the count on the subcommand so for that purpose the current behavior of not incrementing the count makes a lot of sense.
That being said there are cases where you want the subcommand to be triggered from a file. So what I am doing in #362 is adding a configurable flag (like exists on options) that is off by default but if that is set then subcommands can be triggered via config file even if they were not present in the actual command line. Which should create the expected behavior in this issue, once completed and tested.
I use an INI file to configure my app and cmd line arguments to overwrite some of it's properties.
Trying to figure out which options are set from the INI, by not passing any arguments from the cmd line, I realized that
app.got_subcommnad(sApp)
is alwaysfalse
.Additionally, the
->required()
flag that I set to some of the sub-commnads options is ignored at the INI level.I temporarily fixed the issue by extending
_parse_single_config
to call->increment_parsed()
for the sub-commands, i.e.,and appears to resolve my issues. I don't really have an overview of the arch to figure out whether there are side effects by doing so. Any suggestions?
The text was updated successfully, but these errors were encountered: