-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Respect display order #6142
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
base: master
Are you sure you want to change the base?
Respect display order #6142
Conversation
Likely won't get to this until Monday but a couple of notes
|
456552a
to
3838990
Compare
} | ||
|
||
#[test] | ||
fn configured_subcmd_order() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add all new tests in the first commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all of the commits had been squashed. What you did with the test commit before the main commit was right, just more tests had been added in the "fixup".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, I misunderstood then. I've now split the commit into everything test related and then the fix itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the the commits should still be atomic, including each commit passing tests. The first commit should pass, showing the current behavior. The second commit should still pass, showing the new behavior.
The intent with this split is to
- Verify the tests test the right behavior by seeing them change
- Provide a visual demonstration of what this PR accomplishes by the diff between the two commits
36cc073
to
cbeb0ba
Compare
In clap-rs#3362 we have an issue where when we configure an arg via .display_order(int), and then generate a manpage, the synposis and options will render the order the args were provided to the App rather than the order they were configured e.g Command::new(name) arg(Arg::new("few").short('b').display_order(2)) arg(Arg::new("bar").short('a').display_order(1)) will show ... SYNOPSIS <name> [-b] [-a] ... ... OPTIONS -b -a instead of ... SYNOPSIS <name> [-a] [-b] ... ... OPTIONS -a -b and so on. This fix adds sorting in the synopsis and options functions responsible for generating the corresponding synopsis and options sections of the manpage.
cbeb0ba
to
1f07ad2
Compare
This is branched off #6072 and fixes #3362. The work over at #6072 seems to have stalled. With this PR, I'd like to get the feature ready and merged.
My changes (see last commit) should resolve the comments left on the original PR. Additionally, I noticed that
option_sort_key
was fully copy/pasted on the original PR. I tried to reuse the logic and ended up creatingArgOrder
. Not fully sure if this is the way to go, but I think it's quite a bit better than the current state. Especially the bit with theBTreeMap
was unnecessary andpositional_sort_key
was a overly complicated way of saying "don't do anything".Maybe you would like to implement or name
ArgOrder
differently? Also I'm not sure where I should placeArgOrder
in order to be usable in both places.