Skip to content

Commit 6c53684

Browse files
committed
feat(cli/rustup-mode): add --force-non-host to rustup default
1 parent 8df6d01 commit 6c53684

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/cli/rustup_mode.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ enum RustupSubcmd {
161161
Default {
162162
#[arg(help = MAYBE_RESOLVABLE_TOOLCHAIN_ARG_HELP)]
163163
toolchain: Option<MaybeResolvableToolchainName>,
164+
165+
/// Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains
166+
#[arg(long)]
167+
force_non_host: bool,
164168
},
165169

166170
/// Modify or query the installed toolchains
@@ -631,7 +635,10 @@ pub async fn main(
631635
ToolchainSubcmd::Uninstall { opts } => toolchain_remove(cfg, opts),
632636
},
633637
RustupSubcmd::Check => check_updates(cfg).await,
634-
RustupSubcmd::Default { toolchain } => default_(cfg, toolchain).await,
638+
RustupSubcmd::Default {
639+
toolchain,
640+
force_non_host,
641+
} => default_(cfg, toolchain, force_non_host).await,
635642
RustupSubcmd::Target { subcmd } => match subcmd {
636643
TargetSubcmd::List {
637644
toolchain,
@@ -710,6 +717,7 @@ pub async fn main(
710717
async fn default_(
711718
cfg: &Cfg<'_>,
712719
toolchain: Option<MaybeResolvableToolchainName>,
720+
force_non_host: bool,
713721
) -> Result<utils::ExitCode> {
714722
common::warn_if_host_is_emulated(cfg.process);
715723

@@ -725,7 +733,7 @@ async fn default_(
725733
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
726734
let desc = toolchain.resolve(&cfg.get_default_host_triple()?)?;
727735
let status = cfg
728-
.ensure_installed(&desc, vec![], vec![], None, false, true)
736+
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true)
729737
.await?
730738
.0;
731739

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ stdout = """
44
...
55
Set the default toolchain
66
7-
Usage: rustup[EXE] default [TOOLCHAIN]
7+
Usage: rustup[EXE] default [OPTIONS] [TOOLCHAIN]
88
99
Arguments:
1010
[TOOLCHAIN] 'none', a toolchain name, such as 'stable', 'nightly', '1.8.0', or a custom toolchain
1111
name. For more information see `rustup help toolchain`
1212
1313
Options:
14-
-h, --help Print help
14+
--force-non-host Install toolchains that require an emulator. See
15+
https://github.com/rust-lang/rustup/wiki/Non-host-toolchains
16+
-h, --help Print help
1517
1618
Discussion:
1719
Sets the default toolchain to the one specified. If the toolchain

0 commit comments

Comments
 (0)