diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 14b48241ce..ee6b686e4c 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -468,6 +468,10 @@ struct UpdateOpts { /// Set the installed toolchain as the override for the current directory #[arg(long)] r#override: bool, + + /// Set the installed toolchain as the default toolchain + #[arg(long)] + default: bool, } #[derive(Debug, Default, Args)] @@ -1059,7 +1063,6 @@ async fn update( let self_update_mode = SelfUpdateMode::from_cfg(cfg)?; let should_self_update = !opts.no_self_update; let force_non_host = opts.force_non_host; - let set_override = opts.r#override; cfg.profile_override = opts.profile; let cfg = &cfg; @@ -1118,11 +1121,13 @@ async fn update( Ok(status.clone()), )?; - if set_override { + if opts.r#override { cfg.make_override(&cfg.current_dir, &desc.clone().into())?; } - if cfg.get_default()?.is_none() && matches!(status, UpdateStatus::Installed) { + if opts.default + || (cfg.get_default()?.is_none() && matches!(status, UpdateStatus::Installed)) + { cfg.set_default(Some(&desc.into()))?; } } diff --git a/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg b/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg index f996dc9902..d42f1d8930 100644 --- a/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg +++ b/tests/suite/cli_rustup_ui/rustup_toolchain_cmd_install_cmd_help_flag.stdout.term.svg @@ -1,4 +1,4 @@ - +