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): Shift focus to subcommands, when present #4125

Merged
merged 1 commit into from
Aug 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ MSRV is now 1.60.0
- *(help)* Show when a flag is `ArgAction::Count` by adding an `...`
- *(help)* Use a more neutral palette for coloring
- *(help)* Don't rely on ALL CAPS for help headers
- *(help)* List subcommands first, focusing the emphasis on them
- *(version)* Use `Command::display_name` rather than `Command::bin_name`
- *(parser)* Assert on unknown args when using external subcommands (#3703)
- *(parser)* Always fill in `""` argument for external subcommands (#3263)
Expand Down
6 changes: 3 additions & 3 deletions examples/cargo-example-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ cargo
Usage:
cargo <SUBCOMMAND>

Options:
-h, --help Print help information

Subcommands:
example-derive A simple to use, efficient, and full-featured Command Line Argument Parser
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information

$ cargo-example-derive example-derive --help
cargo-example-derive [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand Down
6 changes: 3 additions & 3 deletions examples/cargo-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ cargo
Usage:
cargo <SUBCOMMAND>

Options:
-h, --help Print help information

Subcommands:
example A simple to use, efficient, and full-featured Command Line Argument Parser
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information

$ cargo-example example --help
cargo-example [..]
A simple to use, efficient, and full-featured Command Line Argument Parser
Expand Down
8 changes: 4 additions & 4 deletions examples/derive_ref/interop_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ clap
Usage:
interop_hand_subcommand[EXE] [OPTIONS] <SUBCOMMAND>

Options:
-t, --top-level
-h, --help Print help information

Subcommands:
add
remove
help Print this message or the help of the given subcommand(s)

Options:
-t, --top-level
-h, --help Print help information

```

```console
Expand Down
20 changes: 10 additions & 10 deletions examples/git-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@ A fictional versioning CLI
Usage:
git-derive[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information

Subcommands:
clone Clones repos
push pushes things
add adds things
stash
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information

$ git-derive help
git
A fictional versioning CLI

Usage:
git-derive[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information

Subcommands:
clone Clones repos
push pushes things
add adds things
stash
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information

$ git-derive help add
git-add
adds things
Expand Down Expand Up @@ -84,16 +84,16 @@ Usage:
git-derive[EXE] stash [OPTIONS]
git-derive[EXE] stash <SUBCOMMAND>

Options:
-m, --message <MESSAGE>
-h, --help Print help information

Subcommands:
push
pop
apply
help Print this message or the help of the given subcommand(s)

Options:
-m, --message <MESSAGE>
-h, --help Print help information

$ git-derive stash push -h
git-stash-push

Expand Down
20 changes: 10 additions & 10 deletions examples/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ A fictional versioning CLI
Usage:
git[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information

Subcommands:
clone Clones repos
push pushes things
add adds things
stash
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information

$ git help
git
A fictional versioning CLI

Usage:
git[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information

Subcommands:
clone Clones repos
push pushes things
add adds things
stash
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information

$ git help add
git-add
adds things
Expand Down Expand Up @@ -82,16 +82,16 @@ Usage:
git[EXE] stash [OPTIONS]
git[EXE] stash <SUBCOMMAND>

Options:
-m, --message <MESSAGE>
-h, --help Print help information

Subcommands:
push
pop
apply
help Print this message or the help of the given subcommand(s)

Options:
-m, --message <MESSAGE>
-h, --help Print help information

$ git stash push -h
git-stash-push

Expand Down
8 changes: 4 additions & 4 deletions examples/multicall-busybox.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ busybox
Usage:
busybox [OPTIONS] [APPLET]

Options:
--install <install> Install hardlinks for all subcommands in path
-h, --help Print help information

APPLETS:
true does nothing successfully
false does nothing unsuccessfully
help Print this message or the help of the given subcommand(s)

Options:
--install <install> Install hardlinks for all subcommands in path
-h, --help Print help information

```
8 changes: 4 additions & 4 deletions examples/pacman.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ package manager utility
Usage:
pacman[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
query -Q --query Query the package database.
sync -S --sync Synchronize packages.
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information
-V, --version Print version information

$ pacman -S -h
pacman-sync
Synchronize packages.
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorial_builder/01_quick.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ A simple to use, efficient, and full-featured Command Line Argument Parser
Usage:
01_quick[EXE] [OPTIONS] [name] [SUBCOMMAND]

Subcommands:
test does testing things
help Print this message or the help of the given subcommand(s)

Arguments:
<name> Optional name to operate on

Expand All @@ -15,10 +19,6 @@ Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
test does testing things
help Print this message or the help of the given subcommand(s)

```

By default, the program does nothing:
Expand Down
16 changes: 8 additions & 8 deletions examples/tutorial_builder/03_04_subcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ A simple to use, efficient, and full-featured Command Line Argument Parser
Usage:
03_04_subcommands[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
add Adds files to myapp
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information
-V, --version Print version information

$ 03_04_subcommands help add
clap-add [..]
Adds files to myapp
Expand Down Expand Up @@ -43,14 +43,14 @@ A simple to use, efficient, and full-featured Command Line Argument Parser
Usage:
03_04_subcommands[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
add Adds files to myapp
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information
-V, --version Print version information

```

Because we set [`Command::propagate_version`][crate::Command::propagate_version]:
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorial_derive/01_quick.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ A simple to use, efficient, and full-featured Command Line Argument Parser
Usage:
01_quick_derive[EXE] [OPTIONS] [NAME] [SUBCOMMAND]

Subcommands:
test does testing things
help Print this message or the help of the given subcommand(s)

Arguments:
<NAME> Optional name to operate on

Expand All @@ -15,10 +19,6 @@ Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
test does testing things
help Print this message or the help of the given subcommand(s)

```

By default, the program does nothing:
Expand Down
16 changes: 8 additions & 8 deletions examples/tutorial_derive/03_04_subcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ A simple to use, efficient, and full-featured Command Line Argument Parser
Usage:
03_04_subcommands_derive[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
add Adds files to myapp
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information
-V, --version Print version information

$ 03_04_subcommands_derive help add
clap-add [..]
Adds files to myapp
Expand Down Expand Up @@ -43,14 +43,14 @@ A simple to use, efficient, and full-featured Command Line Argument Parser
Usage:
03_04_subcommands_derive[EXE] <SUBCOMMAND>

Options:
-h, --help Print help information
-V, --version Print version information

Subcommands:
add Adds files to myapp
help Print this message or the help of the given subcommand(s)

Options:
-h, --help Print help information
-V, --version Print version information

```

Because we added `#[clap(propagate_version = true)]`:
Expand Down
Loading