From ec298750e3045ea76bfa5c4e670498cdd668ef86 Mon Sep 17 00:00:00 2001 From: Trevor Miranda Date: Tue, 12 Feb 2019 04:51:55 -0500 Subject: [PATCH 1/4] Bring output `rustup default` with no arguments into line with others --- src/rustup-cli/rustup_mode.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/rustup-cli/rustup_mode.rs b/src/rustup-cli/rustup_mode.rs index 960d32940e..af50c7191b 100644 --- a/src/rustup-cli/rustup_mode.rs +++ b/src/rustup-cli/rustup_mode.rs @@ -592,17 +592,7 @@ fn default_(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> { common::show_channel_update(cfg, toolchain.name(), Ok(status))?; } } else { - let installed_toolchains = cfg.list_toolchains()?; - if installed_toolchains.len() > 0 { - let default_toolchain = cfg.get_default()?; - if default_toolchain != "" { - let mut t = term2::stdout(); - let _ = t.attr(term2::Attr::Bold); - let _ = write!(t, "Default toolchain: "); - let _ = t.reset(); - println!("{}", default_toolchain); - } - } + println!("{} (default)", cfg.get_default()?); } Ok(()) From d6318e47e693be30a7b49b8b0d323d50974380b0 Mon Sep 17 00:00:00 2001 From: Trevor Miranda Date: Tue, 12 Feb 2019 04:52:31 -0500 Subject: [PATCH 2/4] Show reason for `rustup show active-toolchain` when override is set --- src/rustup-cli/rustup_mode.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rustup-cli/rustup_mode.rs b/src/rustup-cli/rustup_mode.rs index af50c7191b..2ae0082ad5 100644 --- a/src/rustup-cli/rustup_mode.rs +++ b/src/rustup-cli/rustup_mode.rs @@ -783,8 +783,12 @@ fn show(cfg: &Cfg) -> Result<()> { fn show_active_toolchain(cfg: &Cfg) -> Result<()> { let ref cwd = utils::current_dir()?; - if let Some((toolchain, _)) = cfg.find_override_toolchain_or_default(cwd)? { - writeln!(term2::stdout(), "{}", toolchain.name())? + if let Some((toolchain, reason)) = cfg.find_override_toolchain_or_default(cwd)? { + if reason.is_some() { + println!("{} ({})", toolchain.name(), reason.unwrap()); + } else { + println!("{} (default)", toolchain.name()); + } } Ok(()) } From 7f8272081594203ebfbdd71256d9e021c10722e3 Mon Sep 17 00:00:00 2001 From: Trevor Miranda Date: Tue, 12 Feb 2019 05:05:43 -0500 Subject: [PATCH 3/4] Update show_active_toolchain test to reflect new output --- tests/cli-rustup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cli-rustup.rs b/tests/cli-rustup.rs index 0ad0c884f2..5d22172ca2 100644 --- a/tests/cli-rustup.rs +++ b/tests/cli-rustup.rs @@ -861,7 +861,7 @@ fn show_active_toolchain() { config, &["rustup", "show", "active-toolchain"], for_host!( - r"nightly-{0} + r"nightly-{0} (default) " ), r"", From 3e9e797664642a08953cbd685fa59949e15d39bf Mon Sep 17 00:00:00 2001 From: Trevor Miranda Date: Mon, 18 Feb 2019 16:25:24 -0500 Subject: [PATCH 4/4] Add show_active_toolchain_with_override test --- tests/cli-rustup.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/cli-rustup.rs b/tests/cli-rustup.rs index 5d22172ca2..966699187e 100644 --- a/tests/cli-rustup.rs +++ b/tests/cli-rustup.rs @@ -869,6 +869,20 @@ fn show_active_toolchain() { }); } +#[test] +fn show_active_toolchain_with_override() { + setup(&|config| { + expect_ok(config, &["rustup", "default", "stable"]); + expect_ok(config, &["rustup", "default", "nightly"]); + expect_ok(config, &["rustup", "override", "set", "stable"]); + expect_stdout_ok( + config, + &["rustup", "show", "active-toolchain"], + for_host!("stable-{0} (directory override for"), + ); + }); +} + #[test] fn show_active_toolchain_none() { setup(&|config| {