-
-
Notifications
You must be signed in to change notification settings - Fork 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
AppSettings::DeriveDisplayOrder doesn't propagate to sub commands correctly #706
Comments
I had a quick look through the source. Seems |
Quick WIP commit of a working solution (at least for this example): https://github.com/Nemo157/clap-rs/tree/derive_order_at_print_time_2 Not sure if this will handle the interaction with EDIT: Just realised this will break explicitly using the |
Thanks for such a detailed write up! I see a possibly simple way to go about fixing this. Since you've already taken the time to check through the code and get a potential fix if you'd like, I'll give my suggestion and answer any questions you've got but let you take the crack at it? Add an Then upon propagating the global settings, if This is just off the top of my head though 😜 Also, it sounds like I need to add a test to guard against this issue in the future! |
That solution would also allow the help generation code to remain unchanged. I'm also open to other solutions, which I forgot to mention. |
I can see how something like that could work, I should be able to throw something together within the next day. |
New WIP commit: Nemo157@2b78c98 Based on your suggestion but slightly different to also handle propagating |
I'll write a couple of quick tests then make a PR for this. |
Try and stress the combinations of DeriveDisplayOrder and UnifiedHelpMessage along with propagating them to subcommands and explicitly setting a display order. The new tests derive_order_subcommand_propagate unified_help_and_derive_order_subcommand_propagate unified_help_and_derive_order_subcommand_propagate_with_explicit_display_order are currently failing because of bug clap-rs#706.
Don't attempt to change the display order of flags/options until any app settings have been propagated down from a parent App in case DeriveDisplayOrder and/or UnifiedHelpMessage are propagated. Fixes clap-rs#706
Don't attempt to change the display order of flags/options until any app settings have been propagated down from a parent App in case DeriveDisplayOrder and/or UnifiedHelpMessage are propagated. Fixes clap-rs#706
Try and stress the combinations of DeriveDisplayOrder and UnifiedHelpMessage along with propagating them to subcommands and explicitly setting a display order. The new tests derive_order_subcommand_propagate unified_help_and_derive_order_subcommand_propagate unified_help_and_derive_order_subcommand_propagate_with_explicit_display_order are currently failing because of bug clap-rs#706.
Excellent! If it passes the prior the tests and some new one(s) for this case I'm good with it! 👍 |
Adding
AppSettings::DeriveDisplayOrder
to the global settings of anApp
doesn't propagate down to the apps sub commands.The following example defines a subcommand with two args in reverse alphabetical order, running
--help
on the subcommand prints the arguments in alphabetical order with the--help
and--version
arguments also interspersed.Moving the
.global_setting(AppSettings::DeriveDisplayOrder)
line down to the subcommand itself results in the correct ordering of the two arguments, so the setting itself is working but for some reason not propagating down correctly.Example code
Output (saved the above example into
examples/derive-display-order-bug.rs
and run viacargo run --example derive-display-order-bug -- test --help
)The text was updated successfully, but these errors were encountered: