Skip to content

Commit de46bab

Browse files
FranciscoTGouveiarami3l
authored andcommitted
feat(toolchain): add --override to override toolchain as soon as installed
1 parent 42bdacf commit de46bab

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/cli/rustup_mode.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ struct UpdateOpts {
402402
/// Install toolchains that require an emulator. See https://github.com/rust-lang/rustup/wiki/Non-host-toolchains
403403
#[arg(long)]
404404
force_non_host: bool,
405+
406+
/// Set the installed toolchain as the override for the current directory
407+
#[arg(long)]
408+
r#override: bool,
405409
}
406410

407411
#[derive(Debug, Default, Args)]
@@ -946,6 +950,7 @@ async fn update(
946950
let self_update_mode = SelfUpdateMode::from_cfg(cfg)?;
947951
let should_self_update = !opts.no_self_update;
948952
let force_non_host = opts.force_non_host;
953+
let set_override = opts.r#override;
949954
cfg.profile_override = opts.profile;
950955

951956
let cfg = &cfg;
@@ -1003,6 +1008,11 @@ async fn update(
10031008
PackageUpdate::Toolchain(desc.clone()),
10041009
Ok(status.clone()),
10051010
)?;
1011+
1012+
if set_override {
1013+
cfg.make_override(&cfg.current_dir, &desc.clone().into())?;
1014+
}
1015+
10061016
if cfg.get_default()?.is_none() && matches!(status, UpdateStatus::Installed) {
10071017
cfg.set_default(Some(&desc.into()))?;
10081018
}

tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg

Lines changed: 15 additions & 13 deletions
Loading

0 commit comments

Comments
 (0)