Skip to content
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 not ordering options by defined order. #949

Closed
Dragonrun1 opened this issue May 8, 2017 · 2 comments
Closed
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations
Milestone

Comments

@Dragonrun1
Copy link

Rust Version

rustc 1.19.0-nightly (f4209651e 2017-05-05)

Affected Version of clap

clap 2.24.1

Expected Behavior Summary

Options and flag appear in same order as they are defined.

Actual Behavior Summary

Some options are moved into a seemingly more alphabetical order instead.
Good example the '-d' option is moved before the '-n' option even though they are define in opposite order. Another is '--ini' moves up several places instead of just before the '--r*' ones where it should be so it seems to be effecting both long and short options.

Steps to Reproduce the issue

Download
Run cargo run --bin test -- -h where 'test' is the downloaded code.
Notice things are not in the defined order.

Example output

@kbknapp
Copy link
Member

kbknapp commented May 8, 2017

This is because you don't have AppSettings::UnifiedHelpMessage set.

I understand you're using the {unified} in the template. Without getting into the weeds, what happens is clap orders flags and options separately (unless UnifiedHelpMessage is set, in which case it merges them at declaration time). Then when printing the help message, if {unified} is used without having also used UnifiedHelpMessage it will do a "best effort" merge.

I'm going to mark this as a documentation issue, as I should probably mention this edge case explicitly.

@kbknapp kbknapp added A-docs Area: documentation, including docs.rs, readme, examples, etc... C: settings C-enhancement Category: Raise on the bar on expectations labels May 8, 2017
@kbknapp kbknapp added this to the 2.24.2 milestone May 9, 2017
@Dragonrun1
Copy link
Author

Okay adding the other setting did the trick thanks. Yeah probably a good idea to document it so you don't end up with another bug report down the road from someone else :)

kbknapp added a commit that referenced this issue May 15, 2017
…ngs::UnifiedHelpMessage when using {unified} tags in the help template

Closes #949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation, including docs.rs, readme, examples, etc... C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants