diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index a7b9addd474..4029139e145 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -55,38 +55,34 @@ pub fn main(config: &mut LazyConfig) -> CliResult { .map(String::as_str) == Some("help") { + let header = style::HEADER.render(); + let literal = style::LITERAL.render(); + let placeholder = style::PLACEHOLDER.render(); + let reset = anstyle::Reset.render(); + let options = CliUnstable::help(); - let non_hidden_options: Vec<(String, String)> = options - .iter() - .filter(|(_, help_message)| *help_message != HIDDEN) - .map(|(name, help)| (name.to_string(), help.to_string())) - .collect(); - let longest_option = non_hidden_options + let max_length = options .iter() + .filter(|(_, help)| *help != HIDDEN) .map(|(option_name, _)| option_name.len()) .max() .unwrap_or(0); - let help_lines: Vec = non_hidden_options + let z_flags = options .iter() - .map(|(option_name, option_help_message)| { - let option_name_kebab_case = option_name.replace("_", "-"); - let padding = " ".repeat(longest_option - option_name.len()); // safe to subtract - format!( - " -Z {}{} -- {}", - option_name_kebab_case, padding, option_help_message - ) + .filter(|(_, help)| *help != HIDDEN) + .map(|(opt, help)| { + let opt = opt.replace("_", "-"); + format!(" {literal}-Z {opt: