-
-
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
Don't leak help_heading
when flattening
#2803
Comments
I'm assuming we'd need to add a |
Oddly enough I ran into exactly this at work the other day.
Yeah that's the best way I can think of to do this in the least obtrusive manner. An alternative would be to have |
Forgot to mention that I had considered this. I assumed people would want the setting to be inherited which this wouldn't allow. For example, clap-verbosity-flag probably wouldn't be so prescriptive as setting its own help heading, relying on inheriting it. We could extend the trait to allow passing in a heading, but I worry about that being a slippery slope for what goes in the trait interface. Granted, now that I say this, the converse to this also needs to be implemented If someone sets the heading on a |
Related to #2785 |
In part, this is just fixing a papercut where someone will try to use the API in the same way between the two but it fails and they'll have to consult the docs / rust-analyzer. The bigger reason is that this is more derive-friendly for dealing with clap-rs#2803 since we will be able to just ask for the current help heading before running the app and then restore it back, rather than having to conditionalize the revert logic.
This will help for clap-rs#2803 so we can capture and restore the help heading around flattened derives.
We normally set all app attributes at the end. This can be changed but will require some work to ensure - Top-level item's doc cmment ins our over flattened - We still support `Args` / `Subcommand` be used to initialize an `App` when creating a subcommand In the mean time, this special cases `help_heading` to happen first. We'll need this special casing anyways to address clap-rs#2803 since we'll need to capture the old help heading before addings args and then restore it after. I guess we could unconditionally do that but its extra work / boilerplate for when people have to dig into their what the derives do. Fixes clap-rs#2785
When working on clap-rs#2803, I noticed a disprecancy in the augment behavior between `Arg`s and `Subcommand`s that makes it so `Arg`s can't be flattened with the update functionality.
When working on clap-rs#2803, I noticed a disprecancy in the augment behavior between `Arg`s and `Subcommand`s that makes it so `Arg`s can't be flattened with the update functionality.
We normally set all app attributes at the end. This can be changed but will require some work to ensure - Top-level item's doc cmment ins our over flattened - We still support `Args` / `Subcommand` be used to initialize an `App` when creating a subcommand In the mean time, this special cases `help_heading` to happen first. We'll need this special casing anyways to address clap-rs#2803 since we'll need to capture the old help heading before addings args and then restore it after. I guess we could unconditionally do that but its extra work / boilerplate for when people have to dig into their what the derives do. Fixes clap-rs#2785
When working on clap-rs#2803, I noticed a disprecancy in the augment behavior between `Arg`s and `Subcommand`s that makes it so `Arg`s can't be flattened with the update functionality.
Before, when `flatten`ing, the struct you flattened in could set the help heading for all the following arguments. Now, we scope each `flatten` to not do that. I had originally intended to bake this into the initial / final methods but that would have required some re-work to allow capturing state between them that seemed unnecessary. Fixes clap-rs#2803
Please complete the following tasks
Rust Version
rustc 1.55.0 (c8dfcfe04 2021-09-06)
Clap Version
v3.0.0-beta.4
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- --help
Actual Behaviour
option_b
is in "HEADING A"Expected Behaviour
option_b
should be in `GeneralAdditional Context
This is split out of #2785.
Similarly, we should also support setting
help_heading
when specifyingflatten
and it should push and pop the heading.Debug Output
No response
The text was updated successfully, but these errors were encountered: