Skip to content

Commit 8983028

Browse files
committed
refactor(cli): rewrite rustup (toolchain|update|(un)?install) with clap-derive
1 parent e92b85e commit 8983028

15 files changed

+245
-241
lines changed

src/cli/rustup_mode.rs

Lines changed: 205 additions & 192 deletions
Large diffs are not rendered by default.

src/toolchain/names.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,6 @@ impl Display for CustomToolchainName {
458458
}
459459
}
460460

461-
/// Thunk to avoid
462-
/// = note: `fn(&'2 str) -> Result<CustomToolchainName, <CustomToolchainName as TryFrom<&'2 str>>::Error> {<CustomToolchainName as TryFrom<&'2 str>>::try_from}` must implement `FnOnce<(&'1 str,)>`, for any lifetime `'1`...
463-
/// = note: ...but it actually implements `FnOnce<(&'2 str,)>`, for some specific lifetime `'2`
464-
pub(crate) fn custom_toolchain_name_parser(
465-
value: &str,
466-
) -> Result<CustomToolchainName, InvalidName> {
467-
CustomToolchainName::try_from(value)
468-
}
469-
470461
/// An toolchain specified just via its path. Relative paths enable arbitrary
471462
/// code execution in a rust dir, so as a partial mitigation is limited to
472463
/// absolute paths.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bin.name = "rustup"
2-
args = ["component","add","--help"]
2+
args = ["component", "add", "--help"]
33
stdout = """
44
...
55
Add a component to a Rust toolchain

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bin.name = "rustup"
2-
args = ["component","remove","--help"]
2+
args = ["component", "remove", "--help"]
33
stdout = """
44
...
55
Remove a component from a Rust toolchain

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ The Rust toolchain installer
99
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
1010
1111
Commands:
12-
show Show the active and installed toolchains or profiles
13-
update Update Rust toolchains and rustup
1412
check Check for updates to Rust toolchains and rustup
1513
default Set the default toolchain
16-
toolchain Modify or query the installed toolchains
1714
target Modify a toolchain's supported targets
1815
component Modify a toolchain's installed components
1916
override Modify toolchain overrides for directories
@@ -24,6 +21,9 @@ Commands:
2421
self Modify the rustup installation
2522
set Alter rustup settings
2623
completions Generate tab-completion scripts for your shell
24+
show Show the active and installed toolchains or profiles
25+
update Update Rust toolchains and rustup
26+
toolchain Modify or query the installed toolchains
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@ The Rust toolchain installer
99
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
1010
1111
Commands:
12-
show Show the active and installed toolchains or profiles
13-
update Update Rust toolchains and rustup
1412
check Check for updates to Rust toolchains and rustup
1513
default Set the default toolchain
16-
toolchain Modify or query the installed toolchains
1714
target Modify a toolchain's supported targets
1815
component Modify a toolchain's installed components
1916
override Modify toolchain overrides for directories
@@ -24,6 +21,9 @@ Commands:
2421
self Modify the rustup installation
2522
set Alter rustup settings
2623
completions Generate tab-completion scripts for your shell
24+
show Show the active and installed toolchains or profiles
25+
update Update Rust toolchains and rustup
26+
toolchain Modify or query the installed toolchains
2727
help Print this message or the help of the given subcommand(s)
2828
2929
Arguments:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ rustup [..]
66
77
The Rust toolchain installer
88
9-
Usage: rustup [OPTIONS] [+toolchain] [COMMAND]
9+
Usage: rustup[EXE] [OPTIONS] [+toolchain] [COMMAND]
1010
1111
Commands:
12-
show Show the active and installed toolchains or profiles
13-
update Update Rust toolchains and rustup
1412
check Check for updates to Rust toolchains and rustup
1513
default Set the default toolchain
16-
toolchain Modify or query the installed toolchains
1714
target Modify a toolchain's supported targets
1815
component Modify a toolchain's installed components
1916
override Modify toolchain overrides for directories
@@ -24,6 +21,9 @@ Commands:
2421
self Modify the rustup installation
2522
set Alter rustup settings
2623
completions Generate tab-completion scripts for your shell
24+
show Show the active and installed toolchains or profiles
25+
update Update Rust toolchains and rustup
26+
toolchain Modify or query the installed toolchains
2727
help Print this message or the help of the given subcommand(s)
2828
2929
Arguments:
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
bin.name = "rustup"
2-
args = ["toolchain","install","--help"]
2+
args = ["toolchain", "install", "--help"]
33
stdout = """
44
...
55
Install or update a given toolchain
66
7-
Usage: rustup[EXE] toolchain install [OPTIONS] <toolchain>...
7+
Usage: rustup[EXE] toolchain install [OPTIONS] <TOOLCHAIN>...
88
99
Arguments:
10-
<toolchain>... Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
10+
<TOOLCHAIN>... Toolchain name, such as 'stable', 'nightly', or '1.8.0'. For more information see
1111
`rustup help toolchain`
1212
1313
Options:
14-
--profile <profile> [possible values: minimal, default, complete]
15-
-c, --component <components>... Add specific components on installation
16-
-t, --target <targets>... Add specific targets on installation
17-
--no-self-update Don't perform self update when running the`rustup toolchain
18-
install` command
19-
--force Force an update, even if some components are missing
20-
--allow-downgrade Allow rustup to downgrade the toolchain to satisfy your component
21-
choice
22-
--force-non-host Install toolchains that require an emulator. See
23-
https://github.com/rust-lang/rustup/wiki/Non-host-toolchains
24-
-h, --help Print help
14+
--profile <PROFILE> [possible values: minimal, default, complete]
15+
-c, --component <COMPONENT>... Add specific components on installation
16+
-t, --target <TARGET>... Add specific targets on installation
17+
--no-self-update Don't perform self update when running the `rustup toolchain
18+
install` command
19+
--force Force an update, even if some components are missing
20+
--allow-downgrade Allow rustup to downgrade the toolchain to satisfy your component
21+
choice
22+
--force-non-host Install toolchains that require an emulator. See
23+
https://github.com/rust-lang/rustup/wiki/Non-host-toolchains
24+
-h, --help Print help
2525
"""
2626
stderr = ""

tests/suite/cli-ui/rustup/rustup_toolchain_cmd_link_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 = ["toolchain","link","--help"]
2+
args = ["toolchain", "link", "--help"]
33
stdout = """
44
...
55
Create a custom toolchain by symlinking to a directory
66
7-
Usage: rustup[EXE] toolchain link <toolchain> <path>
7+
Usage: rustup[EXE] toolchain link <TOOLCHAIN> <PATH>
88
99
Arguments:
10-
<toolchain> Custom toolchain name
11-
<path> Path to the directory
10+
<TOOLCHAIN> Custom toolchain name
11+
<PATH> Path to the directory
1212
1313
Options:
1414
-h, --help Print help

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ stdout = """
44
...
55
Uninstall a toolchain
66
7-
Usage: rustup[EXE] toolchain uninstall <toolchain>...
7+
Usage: rustup[EXE] toolchain uninstall <TOOLCHAIN>...
88
99
Arguments:
10-
<toolchain>... Toolchain name, such as 'stable', 'nightly', '1.8.0', or a custom toolchain name.
10+
<TOOLCHAIN>... Toolchain name, such as 'stable', 'nightly', '1.8.0', or a custom toolchain name.
1111
For more information see `rustup help toolchain`
1212
1313
Options:

0 commit comments

Comments
 (0)