Skip to content

Commit

Permalink
Merge pull request #3470 from epage/pacman
Browse files Browse the repository at this point in the history
fix(help): Improve pacman help output
  • Loading branch information
epage authored Feb 15, 2022
2 parents 182e573 + 3475555 commit bbf4722
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions examples/pacman.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ 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)
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
Synchronize packages.

USAGE:
pacman[EXE] {sync, --sync, -S} [OPTIONS] [--] [package]...
pacman[EXE] {sync|--sync|-S} [OPTIONS] [--] [package]...

ARGS:
<package>... packages
Expand All @@ -77,7 +77,7 @@ $ pacman -S -s foo -i bar
error: The argument '--search <search>...' cannot be used with '--info'

USAGE:
pacman[EXE] {sync, --sync, -S} --search <search>... <package>...
pacman[EXE] {sync|--sync|-S} --search <search>... <package>...

For more information try --help

Expand Down
4 changes: 2 additions & 2 deletions src/build/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4003,11 +4003,11 @@ impl<'help> App<'help> {
let mut sc_names = sc.name.clone();
let mut flag_subcmd = false;
if let Some(l) = sc.long_flag {
write!(sc_names, ", --{}", l).unwrap();
write!(sc_names, "|--{}", l).unwrap();
flag_subcmd = true;
}
if let Some(s) = sc.short_flag {
write!(sc_names, ", -{}", s).unwrap();
write!(sc_names, "|-{}", s).unwrap();
flag_subcmd = true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/output/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
write!(sc_str, " -{}", short).unwrap();
}
if let Some(long) = subcommand.get_long_flag() {
write!(sc_str, "--{}", long).unwrap();
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));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/builder/flag_subcommands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ static FLAG_SUBCOMMAND_HELP: &str = "pacman-query
Query the package database.
USAGE:
pacman {query, --query, -Q} [OPTIONS]
pacman {query|--query|-Q} [OPTIONS]
OPTIONS:
-h, --help Print help information
Expand Down Expand Up @@ -507,7 +507,7 @@ static FLAG_SUBCOMMAND_NO_SHORT_HELP: &str = "pacman-query
Query the package database.
USAGE:
pacman {query, --query} [OPTIONS]
pacman {query|--query} [OPTIONS]
OPTIONS:
-h, --help Print help information
Expand Down Expand Up @@ -560,7 +560,7 @@ static FLAG_SUBCOMMAND_NO_LONG_HELP: &str = "pacman-query
Query the package database.
USAGE:
pacman {query, -Q} [OPTIONS]
pacman {query|-Q} [OPTIONS]
OPTIONS:
-h, --help Print help information
Expand Down

0 comments on commit bbf4722

Please sign in to comment.