-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Please default to DisableVersionForSubcommands #2812
Comments
I'll be upfront, I'm unsure how we should go about a decision like this. Something that might help is if we have an idea what precedent there is for current behavior and any of the proposed behaviors like we did for #2808 |
Forgot to mention, this is being carried over from #2627 (comment) Two concerns I raised there
|
Agreed that subcommands are rarely individually versioned. I'd be in favor of making the global version the default. As for wanting to hide or disable Actually...now that I think about it. Why do we build/show a |
To be clear, I'd like to address the building a Making global versions the default could then be either addressed separately and either kicked down the road, or rejected. |
This commit changes the default behavior of clap to no longer generate a `-V, --version` flag when no version information via `App::version` or `App::long_version` has been provided. This removes the requirement for `AppSettings::DisableVersionFlag`. Additionally, `AppSettings::DisableVersionForSubcommands` is no longer required since if no `--version` flag is built, no version flag can be propagated down to subcommands. Technically, clap still generates a version flag, however it is removed prior to parsing if the user had not provided any version information. This means that one can also still `App::mut_arg("version", |ver_flag| ...)` when changing the default version flag behavior is desired. Doing so will "add version information" and cause clap to not remove this flag. Relates to #2812 wip: removing DisableVersionFlag and DisableVersionForSubcommands
This commit fixes up all tests to the new bevaior of no longer generating a `-V, --version` flag unless the user has provided version information. Relates to #2812
This commit changes the default behavior of clap to no longer generate a `-V, --version` flag when no version information has been provided. Version information can be provided via `App::version`, `App::long_version`, or via `App::mut_arg("version", |_| ..)`. Using any of the above is the only way to have clap auto-generate the version flag. Technically, clap still generates a version flag, however it is removed prior to parsing if the user has not provided any version information via one of the mentioned methods. Relates to [#2812](#2812)
…ubcommands] Because clap no longer auto-generates a version flag when there is no version information, this removes the requirement for `AppSettings::DisableVersionFlag`. Additionally, `AppSettings::DisableVersionForSubcommands` is no longer required since if no `--version` flag is built, no version flag can be propagated down to subcommands. Relates to #2812
…ubcommands] BREAKING CHANGE Because clap no longer auto-generates a version flag when there is no version information, this removes the requirement for `AppSettings::DisableVersionFlag`. Additionally, `AppSettings::DisableVersionForSubcommands` is no longer required since if no `--version` flag is built, no version flag can be propagated down to subcommands. Relates to #2812
This commit changes the default behavior of clap to no longer generate a `-V, --version` flag when no version information has been provided. Version information can be provided via `App::version`, `App::long_version`, or via `App::mut_arg("version", |_| ..)`. Using any of the above is the only way to have clap auto-generate the version flag. Technically, clap still generates a version flag, however it is removed prior to parsing if the user has not provided any version information via one of the mentioned methods. Relates to [#2812](#2812)
This commit changes the default behavior of clap to no longer generate a `-V, --version` flag when no version information has been provided. Version information can be provided via `App::version`, `App::long_version`, or via `App::mut_arg("version", |_| ..)`. Using any of the above is the only way to have clap auto-generate the version flag. Technically, clap still generates a version flag, however it is removed prior to parsing if the user has not provided any version information via one of the mentioned methods. Relates to [#2812](#2812)
FWIW, another approach to solve this would be a different method to set the version, which only sets it for the top level command; effectively, combine setting version with setting a common option about --version. That can be done post-3.0, so I don't think it needs to be a blocker. |
Please complete the following tasks
Clap Version
3.0.0-beta.4
Describe your use case
I have various subcommands, each of which has various options, and in the help for those subcommands, the display space and cognitive space of the user is precious. I don't want to show the
--version
option on subcommands, because it takes up one more line and one more bit of "complexity at a glance".Describe the solution you'd like
I'd propose that either
DisableVersionForSubcommands
should become the default, or a newHideVersionForSubcommands
should become the default.Alternatives, if applicable
I think it'd be fine if
--version
worked on subcommands; I just don't want it to show up in the help output. So, aHideVersionForSubcommands
option would be fine, and would avoid any potential backwards compatibility issues.Additional Context
No response
The text was updated successfully, but these errors were encountered: