Respect the configured display order#6141
Closed
thomas-zahner wants to merge 2 commits intoclap-rs:masterfrom
Closed
Respect the configured display order#6141thomas-zahner wants to merge 2 commits intoclap-rs:masterfrom
thomas-zahner wants to merge 2 commits intoclap-rs:masterfrom
Conversation
Member
|
FYI there is also #6072 |
epage
reviewed
Sep 26, 2025
clap_builder/src/mkeymap.rs
Outdated
Comment on lines
98
to
99
| self.args.sort_by(|a, b| { | ||
| HelpTemplate::option_sort_key(a).cmp(&HelpTemplate::option_sort_key(b)) |
Member
There was a problem hiding this comment.
It is an interesting idea to always store the arguments in sort-order. We wouldn't want to do this on push though as that can be quite slow (unless we are finding the location that matches the sort order and inserting directly there'). We'd instead want to do this in _build.
The question is if this display-only decision should be made always, when most of the time the display is not being used.
Contributor
Author
There was a problem hiding this comment.
Thanks, I also realised that is probably not quite what we want, so I changed it with the second commit.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt to make mangen respect the display order for args. (not yet for subcommands) The implementation is minimalistic with as few changes as possible. It's probably not be quite what we want to merge, which is why I've marked it as draft.
The failing tests also show that currently the change reorders too much. I will probably have dig a bit deeper to understand why this happens, but maybe somebody knows.
Fixes #3362