Skip to content

Commit 5d389e7

Browse files
committed
fixup! refactor(cli): rewrite rustup (man|completions) with clap-derive
1 parent 0ba1e1f commit 5d389e7

File tree

7 files changed

+19
-18
lines changed

7 files changed

+19
-18
lines changed

src/cli/rustup_mode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ enum RustupSubcmd {
221221
Completions {
222222
shell: Shell,
223223

224-
#[arg(default_missing_value = "rustup")]
224+
#[arg(default_value = "rustup")]
225225
command: CompletionCommand,
226226
},
227227
}
@@ -521,6 +521,7 @@ impl Rustup {
521521
topic,
522522
page,
523523
} => doc(cfg, path, toolchain, topic.as_deref(), &page),
524+
#[cfg(not(windows))]
524525
RustupSubcmd::Man { command, toolchain } => man(cfg, &command, toolchain),
525526
RustupSubcmd::Completions { shell, command } => {
526527
output_completion_script(shell, command)

tests/suite/cli-ui/rustup/rustup_completions_cmd_help_flag_stdout.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
bin.name = "rustup"
2-
args = ["completions","--help"]
2+
args = ["completions", "--help"]
33
stdout = """
44
...
55
Generate tab-completion scripts for your shell
66
7-
Usage: rustup[EXE] completions [shell] [command]
7+
Usage: rustup[EXE] completions <SHELL> <COMMAND>
88
99
Arguments:
10-
[shell] [possible values: bash, elvish, fish, powershell, zsh]
11-
[command] [possible values: rustup, cargo]
10+
<SHELL> [possible values: bash, elvish, fish, powershell, zsh]
11+
<COMMAND> [default: rustup] [possible values: rustup, cargo]
1212
1313
Options:
1414
-h, --help Print help

tests/suite/cli-ui/rustup/rustup_help_cmd_stdout.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ The Rust toolchain installer
99
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
1010
1111
Commands:
12-
...
1312
self Modify the rustup installation
1413
set Alter rustup settings
15-
completions Generate tab-completion scripts for your shell
1614
show Show the active and installed toolchains or profiles
1715
update Update Rust toolchains and rustup
1816
check Check for updates to Rust toolchains and rustup
@@ -24,6 +22,8 @@ Commands:
2422
run Run a command with an environment configured for a given toolchain
2523
which Display which binary will be run for a given command
2624
doc Open the documentation for the current toolchain
25+
...
26+
completions Generate tab-completion scripts for your shell
2727
help Print this message or the help of the given subcommand(s)
2828
2929
Arguments:

tests/suite/cli-ui/rustup/rustup_help_flag_stdout.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ The Rust toolchain installer
99
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
1010
1111
Commands:
12-
...
1312
self Modify the rustup installation
1413
set Alter rustup settings
15-
completions Generate tab-completion scripts for your shell
1614
show Show the active and installed toolchains or profiles
1715
update Update Rust toolchains and rustup
1816
check Check for updates to Rust toolchains and rustup
@@ -24,6 +22,8 @@ Commands:
2422
run Run a command with an environment configured for a given toolchain
2523
which Display which binary will be run for a given command
2624
doc Open the documentation for the current toolchain
25+
...
26+
completions Generate tab-completion scripts for your shell
2727
help Print this message or the help of the given subcommand(s)
2828
2929
Arguments:

tests/suite/cli-ui/rustup/rustup_man_cmd_help_flag_stdout.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
bin.name = "rustup"
2-
args = ["man","--help"]
2+
args = ["man", "--help"]
33
stdout = """
44
...
55
View the man page for a given command
66
7-
Usage: rustup[EXE] man [OPTIONS] <command>
7+
Usage: rustup[EXE] man [OPTIONS] <COMMAND>
88
99
Arguments:
10-
<command>
10+
<COMMAND>
1111
1212
Options:
13-
--toolchain <toolchain> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
13+
--toolchain <TOOLCHAIN> Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more
1414
information see `rustup help toolchain`
1515
-h, --help Print help
1616
"""

tests/suite/cli-ui/rustup/rustup_only_options_stdout.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ The Rust toolchain installer
99
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
1010
1111
Commands:
12-
...
1312
self Modify the rustup installation
1413
set Alter rustup settings
15-
completions Generate tab-completion scripts for your shell
1614
show Show the active and installed toolchains or profiles
1715
update Update Rust toolchains and rustup
1816
check Check for updates to Rust toolchains and rustup
@@ -24,6 +22,8 @@ Commands:
2422
run Run a command with an environment configured for a given toolchain
2523
which Display which binary will be run for a given command
2624
doc Open the documentation for the current toolchain
25+
...
26+
completions Generate tab-completion scripts for your shell
2727
help Print this message or the help of the given subcommand(s)
2828
2929
Arguments:

tests/suite/cli_misc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,11 +798,11 @@ fn completion_bad_shell() {
798798
setup(&|config| {
799799
config.expect_err(
800800
&["rustup", "completions", "fake"],
801-
r#"error: invalid value 'fake' for '[shell]'"#,
801+
r#"error: invalid value 'fake' for '[SHELL]'"#,
802802
);
803803
config.expect_err(
804804
&["rustup", "completions", "fake", "cargo"],
805-
r#"error: invalid value 'fake' for '[shell]'"#,
805+
r#"error: invalid value 'fake' for '[SHELL]'"#,
806806
);
807807
});
808808
}
@@ -812,7 +812,7 @@ fn completion_bad_tool() {
812812
setup(&|config| {
813813
config.expect_err(
814814
&["rustup", "completions", "bash", "fake"],
815-
r#"error: invalid value 'fake' for '[command]'"#,
815+
r#"error: invalid value 'fake' for '[COMMAND]'"#,
816816
);
817817
});
818818
}

0 commit comments

Comments
 (0)