Skip to content

Commit f78aa86

Browse files
authored
Merge pull request #3291 from hi-rustin/rustin-patch-SubcommandRequiredElseHelp
Set SubcommandRequiredElseHelp correctly
2 parents ef329e1 + ee000fe commit f78aa86

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

src/cli/rustup_mode.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub(crate) fn cli() -> Command<'static> {
226226
.about("The Rust toolchain installer")
227227
.after_help(RUSTUP_HELP)
228228
.global_setting(AppSettings::DeriveDisplayOrder)
229-
.arg_required_else_help(true)
229+
.setting(AppSettings::SubcommandRequiredElseHelp)
230230
.arg(
231231
verbose_arg("Enable verbose output"),
232232
)
@@ -369,8 +369,7 @@ pub(crate) fn cli() -> Command<'static> {
369369
Command::new("toolchain")
370370
.about("Modify or query the installed toolchains")
371371
.after_help(TOOLCHAIN_HELP)
372-
.subcommand_required(true)
373-
.arg_required_else_help(true)
372+
.setting(AppSettings::SubcommandRequiredElseHelp)
374373
.subcommand(
375374
Command::new("list")
376375
.about("List installed toolchains")
@@ -475,8 +474,7 @@ pub(crate) fn cli() -> Command<'static> {
475474
.subcommand(
476475
Command::new("target")
477476
.about("Modify a toolchain's supported targets")
478-
.subcommand_required(true)
479-
.arg_required_else_help(true)
477+
.setting(AppSettings::SubcommandRequiredElseHelp)
480478
.subcommand(
481479
Command::new("list")
482480
.about("List installed and available targets")
@@ -536,8 +534,7 @@ pub(crate) fn cli() -> Command<'static> {
536534
.subcommand(
537535
Command::new("component")
538536
.about("Modify a toolchain's installed components")
539-
.subcommand_required(true)
540-
.arg_required_else_help(true)
537+
.setting(AppSettings::SubcommandRequiredElseHelp)
541538
.subcommand(
542539
Command::new("list")
543540
.about("List installed and available components")
@@ -593,8 +590,7 @@ pub(crate) fn cli() -> Command<'static> {
593590
Command::new("override")
594591
.about("Modify directory toolchain overrides")
595592
.after_help(OVERRIDE_HELP)
596-
.subcommand_required(true)
597-
.arg_required_else_help(true)
593+
.setting(AppSettings::SubcommandRequiredElseHelp)
598594
.subcommand(
599595
Command::new("list").about("List directory toolchain overrides"),
600596
)
@@ -722,8 +718,7 @@ pub(crate) fn cli() -> Command<'static> {
722718
.subcommand(
723719
Command::new("self")
724720
.about("Modify the rustup installation")
725-
.subcommand_required(true)
726-
.arg_required_else_help(true)
721+
.setting(AppSettings::SubcommandRequiredElseHelp)
727722
.subcommand(Command::new("update").about("Download and install updates to rustup"))
728723
.subcommand(
729724
Command::new("uninstall")
@@ -737,8 +732,7 @@ pub(crate) fn cli() -> Command<'static> {
737732
.subcommand(
738733
Command::new("set")
739734
.about("Alter rustup settings")
740-
.subcommand_required(true)
741-
.arg_required_else_help(true)
735+
.setting(AppSettings::SubcommandRequiredElseHelp)
742736
.subcommand(
743737
Command::new("default-host")
744738
.about("The triple used to identify toolchains when not specified")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rustup [..]
66
The Rust toolchain installer
77
88
USAGE:
9-
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
9+
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>
1010
1111
ARGS:
1212
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ rustup [..]
66
The Rust toolchain installer
77
88
USAGE:
9-
rustup[EXE] [OPTIONS] [+toolchain] [SUBCOMMAND]
9+
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>
1010
1111
ARGS:
1212
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
bin.name = "rustup"
2+
args = ["-v"]
3+
status.code = 1
4+
stdout = """
5+
rustup [..]
6+
The Rust toolchain installer
7+
8+
USAGE:
9+
rustup[EXE] [OPTIONS] [+toolchain] <SUBCOMMAND>
10+
11+
ARGS:
12+
<+toolchain> release channel (e.g. +stable) or custom toolchain to set override
13+
14+
OPTIONS:
15+
-v, --verbose Enable verbose output
16+
-q, --quiet Disable progress output
17+
-h, --help Print help information
18+
-V, --version Print version information
19+
20+
SUBCOMMANDS:
21+
show Show the active and installed toolchains or profiles
22+
update Update Rust toolchains and rustup
23+
check Check for updates to Rust toolchains and rustup
24+
default Set the default toolchain
25+
toolchain Modify or query the installed toolchains
26+
target Modify a toolchain's supported targets
27+
component Modify a toolchain's installed components
28+
override Modify directory toolchain overrides
29+
run Run a command with an environment configured for a given toolchain
30+
which Display which binary will be run for a given command
31+
doc Open the documentation for the current toolchain
32+
...
33+
self Modify the rustup installation
34+
set Alter rustup settings
35+
completions Generate tab-completion scripts for your shell
36+
help Print this message or the help of the given subcommand(s)
37+
38+
DISCUSSION:
39+
Rustup installs The Rust Programming Language from the official
40+
release channels, enabling you to easily switch between stable,
41+
beta, and nightly compilers and keep them updated. It makes
42+
cross-compiling simpler with binary builds of the standard library
43+
for common platforms.
44+
45+
If you are new to Rust consider running `rustup doc --book` to
46+
learn Rust.
47+
"""
48+
stderr = ""

0 commit comments

Comments
 (0)