-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not propagate root options into subcommands #614
Comments
The way I would and have handled a situation like this is to create the subcommand separately and not through the add_subcommand method. auto subc=std::make_shared<CLI::App>("description", "sub_command_name"); Then it won't inherit the main app default. But can still be added later via App.add_subcommand(subc); the subcommand name will be the subcommand used in the main app. If you leave the name blank it will ack like an option group. |
I have a similar requirement: I have global options like " But I have one special subcommand (say " Using either the prefix subcommand, or this separate Initially I tried to enable UPDATE: It turns out I can use Another minor issue I'm not sure how to do it. In the |
This is an inverse of #437 and #450
I had the exact opposite situation:
I have an existing application, which accepts flags and options and has no subcommands. Now I want to add subcommands, each with completely different options and not shared with the root options. I also don't want to break the interface for existing users.
The problem is then that I need to keep all the root options and they will propagate to all subcommands. Which is wrong in my case.
This behavior is really hard to change in my application. Basically I need to create another subcommand (let's call it "run"), move all the old root options there, and then to emulate the old behavior to reroute the calls without subcommands to the "run" subcommand. I used callblacks and ended up looking very hairy and I am not sure I handled all the edge cases corerectly (like
--help
needed to be excluded).I'd like a configuration option in CLI11 to be able to tell whether I want root options to be propagated into subcommands or not. Perhaps this should be an option for each
.add_subcommand()
so that it can be decided individually per subcommand.cc @phlptp
The text was updated successfully, but these errors were encountered: