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
If I understand correctly, you expect an error if update is missing after submodule in the parsed string.
Unless a missing argument (or subparser) is required, the parser will not report an error. Since subparsers do not have a required setting, they can never be missing.
But you can add the same logic to the git example with is_subcommand_used.
if (program.is_subcommand_used(submodule_command) &&
!submodule_command.is_subcommand_used(submodule_update_command)) {
std::cout << "submodule command called without update subcommand" << std::endl;
}
I don't believe it is always an error. From a UI view, some authors may prefer that some_exe submodule -h shows that the update subcommand exists. An example from git is the stash command which has list, show, drop, etc. subcommands.
But, others may want to say submodule without update is an error and they can express that condition with is_subcommand_used.
While working with the example of subparsers in the documentation, with
git
:some_exe submodule
is considered valid by the parser, even if the subparser cannot have any other argument than the subparserupdate
.Did I miss something here ?
The text was updated successfully, but these errors were encountered: