Skip to content

Commit b83ef4e

Browse files
committed
Improve "rustup show" output order
1 parent b5d74ac commit b83ef4e

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

src/cli/rustup_mode.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,8 @@ fn show(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
11081108
};
11091109

11101110
let show_installed_toolchains = installed_toolchains.len() > 1;
1111-
let show_active_targets = active_targets.len() > 1;
11121111
let show_active_toolchain = true;
1112+
let show_active_targets = active_targets.len() > 1;
11131113

11141114
// Only need to display headers if we have multiple sections
11151115
let show_headers = [
@@ -1150,27 +1150,6 @@ fn show(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
11501150
};
11511151
}
11521152

1153-
if show_active_targets {
1154-
let mut t = process().stdout().terminal();
1155-
1156-
if show_headers {
1157-
print_header::<Error>(&mut t, "installed targets for active toolchain")?;
1158-
}
1159-
for at in active_targets {
1160-
writeln!(
1161-
t.lock(),
1162-
"{}",
1163-
at.component
1164-
.target
1165-
.as_ref()
1166-
.expect("rust-std should have a target")
1167-
)?;
1168-
}
1169-
if show_headers {
1170-
writeln!(t.lock())?;
1171-
};
1172-
}
1173-
11741153
if show_active_toolchain {
11751154
let mut t = process().stdout().terminal();
11761155

@@ -1208,6 +1187,27 @@ fn show(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
12081187
}
12091188
}
12101189

1190+
if show_active_targets {
1191+
let mut t = process().stdout().terminal();
1192+
1193+
if show_headers {
1194+
print_header::<Error>(&mut t, "installed targets for active toolchain")?;
1195+
}
1196+
for at in active_targets {
1197+
writeln!(
1198+
t.lock(),
1199+
"{}",
1200+
at.component
1201+
.target
1202+
.as_ref()
1203+
.expect("rust-std should have a target")
1204+
)?;
1205+
}
1206+
if show_headers {
1207+
writeln!(t.lock())?;
1208+
};
1209+
}
1210+
12111211
fn print_header<E>(t: &mut ColorableTerminal, s: &str) -> std::result::Result<(), E>
12121212
where
12131213
E: From<std::io::Error>,

tests/suite/cli_rustup.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -709,18 +709,18 @@ fn show_multiple_targets() {
709709
r"Default host: {2}
710710
rustup home: {3}
711711
712-
installed targets for active toolchain
713-
--------------------------------------
714-
715-
{1}
716-
{0}
717-
718712
active toolchain
719713
----------------
720714
721715
nightly-{0} (default)
722716
1.3.0 (xxxx-nightly-2)
723717
718+
installed targets for active toolchain
719+
--------------------------------------
720+
721+
{1}
722+
{0}
723+
724724
",
725725
clitools::MULTI_ARCH1,
726726
clitools::CROSS_ARCH2,
@@ -764,18 +764,18 @@ installed toolchains
764764
stable-{0}
765765
nightly-{0} (default)
766766
767-
installed targets for active toolchain
768-
--------------------------------------
769-
770-
{1}
771-
{0}
772-
773767
active toolchain
774768
----------------
775769
776770
nightly-{0} (default)
777771
1.3.0 (xxxx-nightly-2)
778772
773+
installed targets for active toolchain
774+
--------------------------------------
775+
776+
{1}
777+
{0}
778+
779779
",
780780
clitools::MULTI_ARCH1,
781781
clitools::CROSS_ARCH2,

0 commit comments

Comments
 (0)