Skip to content

Commit 73a8ba4

Browse files
committed
feat(cli): add colors to -Zhelp console output
1 parent c869f5f commit 73a8ba4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/bin/cargo/cli.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
5555
.map(String::as_str)
5656
== Some("help")
5757
{
58+
let header = style::HEADER.render();
59+
let literal = style::LITERAL.render();
60+
let placeholder = style::PLACEHOLDER.render();
61+
let reset = anstyle::Reset.render();
62+
5863
let options = CliUnstable::help();
5964
let non_hidden_options: Vec<(String, String)> = options
6065
.iter()
@@ -71,7 +76,7 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
7176
.map(|(option_name, option_help_message)| {
7277
let option_name_kebab_case = option_name.replace("_", "-");
7378
format!(
74-
" -Z {:<longest_option$} -- {}",
79+
" {literal}-Z {:<longest_option$}{reset} -- {}",
7580
option_name_kebab_case, option_help_message
7681
)
7782
})
@@ -80,11 +85,11 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
8085
drop_println!(
8186
config,
8287
"
83-
Available unstable (nightly-only) flags:
88+
{header}Available unstable (nightly-only) flags:{reset}
8489
8590
{}
8691
87-
Run with 'cargo -Z [FLAG] [COMMAND]'",
92+
Run with '{literal}cargo -Z{reset} {placeholder}[FLAG] [COMMAND]{reset}'",
8893
joined
8994
);
9095
if !config.nightly_features_allowed {

0 commit comments

Comments
 (0)