Skip to content

Commit 5a39089

Browse files
committed
show active-toolchain with rustc info
1 parent 59fa417 commit 5a39089

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/cli/rustup_mode.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn main() -> Result<utils::ExitCode> {
131131
Ok(match matches.subcommand() {
132132
("dump-testament", _) => common::dump_testament()?,
133133
("show", Some(c)) => match c.subcommand() {
134-
("active-toolchain", Some(_)) => handle_epipe(show_active_toolchain(cfg))?,
134+
("active-toolchain", Some(m)) => handle_epipe(show_active_toolchain(cfg, m))?,
135135
("home", Some(_)) => handle_epipe(show_rustup_home(cfg))?,
136136
("profile", Some(_)) => handle_epipe(show_profile(cfg))?,
137137
("keys", Some(_)) => handle_epipe(show_keys(cfg))?,
@@ -243,7 +243,14 @@ pub fn cli() -> App<'static, 'static> {
243243
.subcommand(
244244
SubCommand::with_name("active-toolchain")
245245
.about("Show the active toolchain")
246-
.after_help(SHOW_ACTIVE_TOOLCHAIN_HELP),
246+
.after_help(SHOW_ACTIVE_TOOLCHAIN_HELP)
247+
.arg(
248+
Arg::with_name("verbose")
249+
.help("Enable verbose output with rustc information")
250+
.takes_value(false)
251+
.short("v")
252+
.long("verbose"),
253+
),
247254
)
248255
.subcommand(
249256
SubCommand::with_name("home")
@@ -1182,17 +1189,22 @@ fn show(cfg: &Cfg) -> Result<utils::ExitCode> {
11821189
Ok(utils::ExitCode(0))
11831190
}
11841191

1185-
fn show_active_toolchain(cfg: &Cfg) -> Result<utils::ExitCode> {
1192+
fn show_active_toolchain(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
1193+
let verbose = m.is_present("verbose");
11861194
let cwd = utils::current_dir()?;
11871195
match cfg.find_or_install_override_toolchain_or_default(&cwd) {
11881196
Err(crate::Error(crate::ErrorKind::ToolchainNotSelected, _)) => {}
11891197
Err(e) => return Err(e.into()),
11901198
Ok((toolchain, reason)) => {
11911199
if let Some(reason) = reason {
1192-
writeln!(process().stdout(), "{} ({})", toolchain.name(), reason)?;
1200+
write!(process().stdout(), "{} ({})", toolchain.name(), reason,)?;
11931201
} else {
1194-
writeln!(process().stdout(), "{} (default)", toolchain.name())?;
1202+
write!(process().stdout(), "{} (default)", toolchain.name(),)?;
1203+
}
1204+
if verbose {
1205+
write!(process().stdout(), " - {}", toolchain.rustc_version())?;
11951206
}
1207+
writeln!(process().stdout())?
11961208
}
11971209
}
11981210
Ok(utils::ExitCode(0))

0 commit comments

Comments
 (0)