-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
clap_man should respect the configured display order for args and subcommands #6072
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?
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.
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.
I don't see any issue here. Unless @epage wants to do this with shell completions too in this PR.
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
@@ -1,6 +1,26 @@ | |||
use clap::{Arg, ArgAction}; | |||
use roff::{bold, italic, roman, Inline, Roff}; | |||
|
|||
pub(crate) fn option_sort_key(arg: &Arg) -> (usize, String) { |
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.
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
@@ -1,6 +1,26 @@ | |||
use clap::{Arg, ArgAction}; | |||
use roff::{bold, italic, roman, Inline, Roff}; | |||
|
|||
pub(crate) fn option_sort_key(arg: &Arg) -> (usize, String) { |
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.
This doesn't look like it needs to be pub(crate)
Please clean up the commits for how they should be merged |
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.