Skip to content

Respect the configured display order#6141

Closed
thomas-zahner wants to merge 2 commits intoclap-rs:masterfrom
thomas-zahner:mangen-respect-display-order
Closed

Respect the configured display order#6141
thomas-zahner wants to merge 2 commits intoclap-rs:masterfrom
thomas-zahner:mangen-respect-display-order

Conversation

@thomas-zahner
Copy link
Contributor

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

@epage
Copy link
Member

epage commented Sep 26, 2025

FYI there is also #6072

Comment on lines 98 to 99
self.args.sort_by(|a, b| {
HelpTemplate::option_sort_key(a).cmp(&HelpTemplate::option_sort_key(b))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I also realised that is probably not quite what we want, so I changed it with the second commit.

@thomas-zahner
Copy link
Contributor Author

thomas-zahner commented Sep 26, 2025

FYI there is also #6072

@epage Thanks for your lightning-fast response. Oh, I've totally missed that. My PR is basically a less evolved version to achieve the same thing. So I'll close this PR as it is a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clap_man should respect the configured display order for args and subcommands

2 participants