Skip to content

Commit 198cbc3

Browse files
epagedjc
authored andcommitted
fix: Use HEADER styling in 'rustup show'
Treating top-level key-value pairs as a `HEADER` matches `cargo info`s behavior.
1 parent aaf00f4 commit 198cbc3

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/cli/rustup_mode.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use std::{
1111
};
1212

1313
use anstream::ColorChoice;
14-
use anstyle::Style;
1514
use anyhow::{Context, Error, Result, anyhow};
1615
use clap::{Args, CommandFactory, Parser, Subcommand, ValueEnum, builder::PossibleValue};
16+
use clap_cargo::style::{CONTEXT, HEADER};
1717
use clap_complete::Shell;
1818
use console::style;
1919
use futures_util::stream::StreamExt;
@@ -1089,15 +1089,13 @@ async fn which(
10891089
async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<ExitCode> {
10901090
common::warn_if_host_is_emulated(cfg.process);
10911091

1092-
let bold = Style::new().bold();
1093-
10941092
// Print host triple
10951093
{
10961094
let t = cfg.process.stdout();
10971095
let mut t = t.lock();
10981096
writeln!(
10991097
t,
1100-
"{bold}Default host: {bold:#}{}",
1098+
"{HEADER}Default host: {HEADER:#}{}",
11011099
cfg.get_default_host_triple()?
11021100
)?;
11031101
}
@@ -1108,7 +1106,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<ExitCode> {
11081106
let mut t = t.lock();
11091107
writeln!(
11101108
t,
1111-
"{bold}rustup home: {bold:#}{}",
1109+
"{HEADER}rustup home: {HEADER:#}{}",
11121110
cfg.rustup_dir.display()
11131111
)?;
11141112
writeln!(t)?;
@@ -1163,7 +1161,7 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<ExitCode> {
11631161
(false, false) => "",
11641162
};
11651163

1166-
writeln!(t.lock(), "{toolchain_name}{status_str}")?;
1164+
writeln!(t.lock(), "{toolchain_name}{CONTEXT}{status_str}{CONTEXT:#}")?;
11671165

11681166
if verbose {
11691167
let toolchain = Toolchain::new(cfg, toolchain_name.into())?;
@@ -1216,11 +1214,10 @@ async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<ExitCode> {
12161214
}
12171215

12181216
fn print_header(t: &mut ColorableTerminal, text: &str) -> Result<(), Error> {
1219-
let bold = Style::new().bold();
12201217
let divider = "-".repeat(text.len());
12211218
let mut term_lock = t.lock();
1222-
writeln!(term_lock, "{bold}{text}{bold:#}")?;
1223-
writeln!(term_lock, "{bold}{divider}{bold:#}")?;
1219+
writeln!(term_lock, "{HEADER}{text}{HEADER:#}")?;
1220+
writeln!(term_lock, "{HEADER}{divider}{HEADER:#}")?;
12241221
Ok(())
12251222
}
12261223

tests/suite/cli_rustup_ui/rustup_show_toolchain.stdout.term.svg

Lines changed: 9 additions & 7 deletions
Loading

0 commit comments

Comments
 (0)