Skip to content
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

fix(help): Improve pacman help output #3470

Merged
merged 3 commits into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/pacman.md
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
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
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
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