fix(help): Show subcommand flags in same order as usage

This commit is contained in:
Ed Page 2022-02-14 16:20:03 -06:00
parent 86864b004b
commit 8c5e42e0fb
2 changed files with 3 additions and 3 deletions

View file

@ -49,9 +49,9 @@ OPTIONS:
-V, --version Print version information
SUBCOMMANDS:
-Q--queryquery Query the package database.
-S--syncsync Synchronize packages.
help Print this message or the help of the given subcommand(s)
query-Q--query Query the package database.
sync-S--sync Synchronize packages.
$ pacman -S -h
pacman[EXE]-sync

View file

@ -844,13 +844,13 @@ impl<'help, 'app, 'writer> Help<'help, 'app, 'writer> {
.filter(|subcommand| should_show_subcommand(subcommand))
{
let mut sc_str = String::new();
sc_str.push_str(subcommand.get_name());
if let Some(short) = subcommand.get_short_flag() {
write!(sc_str, "-{}", short).unwrap();
}
if let Some(long) = subcommand.get_long_flag() {
write!(sc_str, "--{}", long).unwrap();
}
sc_str.push_str(subcommand.get_name());
longest = longest.max(display_width(&sc_str));
ord_v.push((subcommand.get_display_order(), sc_str, subcommand));
}