Skip to content

Commit af22bd9

Browse files
committed
Improve "rustup show" output order
1 parent 7659519 commit af22bd9

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/cli/rustup_mode.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,8 @@ fn show(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
11151115
};
11161116

11171117
let show_installed_toolchains = installed_toolchains.len() > 1;
1118-
let show_active_targets = active_targets.len() > 1;
11191118
let show_active_toolchain = true;
1119+
let show_active_targets = active_targets.len() > 1;
11201120

11211121
// Only need to display headers if we have multiple sections
11221122
let show_headers = [
@@ -1158,26 +1158,6 @@ fn show(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
11581158
};
11591159
}
11601160

1161-
if show_active_targets {
1162-
let mut t = term2::stdout();
1163-
if show_headers {
1164-
print_header::<Error>(&mut t, "installed targets for active toolchain")?;
1165-
}
1166-
for at in active_targets {
1167-
writeln!(
1168-
t,
1169-
"{}",
1170-
at.component
1171-
.target
1172-
.as_ref()
1173-
.expect("rust-std should have a target")
1174-
)?;
1175-
}
1176-
if show_headers {
1177-
writeln!(t)?;
1178-
};
1179-
}
1180-
11811161
if show_active_toolchain {
11821162
let mut t = term2::stdout();
11831163
if show_headers {
@@ -1214,6 +1194,26 @@ fn show(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
12141194
}
12151195
}
12161196

1197+
if show_active_targets {
1198+
let mut t = term2::stdout();
1199+
if show_headers {
1200+
print_header::<Error>(&mut t, "installed targets for active toolchain")?;
1201+
}
1202+
for at in active_targets {
1203+
writeln!(
1204+
t,
1205+
"{}",
1206+
at.component
1207+
.target
1208+
.as_ref()
1209+
.expect("rust-std should have a target")
1210+
)?;
1211+
}
1212+
if show_headers {
1213+
writeln!(t)?;
1214+
};
1215+
}
1216+
12171217
fn print_header<E>(t: &mut term2::StdoutTerminal, s: &str) -> std::result::Result<(), E>
12181218
where
12191219
E: From<term::Error> + From<std::io::Error>,

tests/cli-rustup.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,18 @@ fn show_multiple_targets() {
617617
r"Default host: {2}
618618
rustup home: {3}
619619
620-
installed targets for active toolchain
621-
--------------------------------------
622-
623-
{1}
624-
{0}
625-
626620
active toolchain
627621
----------------
628622
629623
nightly-{0} (default)
630624
1.3.0 (xxxx-nightly-2)
631625
626+
installed targets for active toolchain
627+
--------------------------------------
628+
629+
{1}
630+
{0}
631+
632632
",
633633
clitools::MULTI_ARCH1,
634634
clitools::CROSS_ARCH2,
@@ -670,18 +670,18 @@ installed toolchains
670670
stable-{0}
671671
nightly-{0} (default)
672672
673-
installed targets for active toolchain
674-
--------------------------------------
675-
676-
{1}
677-
{0}
678-
679673
active toolchain
680674
----------------
681675
682676
nightly-{0} (default)
683677
1.3.0 (xxxx-nightly-2)
684678
679+
installed targets for active toolchain
680+
--------------------------------------
681+
682+
{1}
683+
{0}
684+
685685
",
686686
clitools::MULTI_ARCH1,
687687
clitools::CROSS_ARCH2,

0 commit comments

Comments
 (0)