clap_man should respect the configured display order for args and subcommands#6072
Closed
ericgumba wants to merge 3 commits intoclap-rs:masterfrom
Closed
clap_man should respect the configured display order for args and subcommands#6072ericgumba wants to merge 3 commits intoclap-rs:masterfrom
ericgumba wants to merge 3 commits intoclap-rs:masterfrom
Conversation
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.
epage
reviewed
Jul 21, 2025
epage
reviewed
Jul 21, 2025
1. Reused sorting method in help_template.rs. 2. More thorough testing of configured ordering, instead of relying solely on snapbox. 3. Added sorting to subcommand section of clap_mangen
epage
reviewed
Jul 29, 2025
| use clap::{Arg, ArgAction}; | ||
| use roff::{bold, italic, roman, Inline, Roff}; | ||
|
|
||
| pub(crate) fn option_sort_key(arg: &Arg) -> (usize, String) { |
Member
There was a problem hiding this comment.
This should be at the bottom of the file, not the top, so people start with the entry points that matter and dig into details as needed
epage
reviewed
Jul 29, 2025
| use clap::{Arg, ArgAction}; | ||
| use roff::{bold, italic, roman, Inline, Roff}; | ||
|
|
||
| pub(crate) fn option_sort_key(arg: &Arg) -> (usize, String) { |
Member
There was a problem hiding this comment.
This doesn't look like it needs to be pub(crate)
Member
|
Please clean up the commits for how they should be merged |
Merged
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.
In #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
[-b] [-a] ...
...
OPTIONS
-b
-a
instead of
...
SYNOPSIS
[-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.