Skip to content

Commit

Permalink
fix(cli): Respect CARGO_TERM_COLOR in '--list' and '-Zhelp'
Browse files Browse the repository at this point in the history
Found this with the test for `-Zhelp` in rust-lang#13461.
  • Loading branch information
epage authored and stupendoussuperpowers committed Feb 28, 2024
1 parent 4491432 commit a9b82ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,22 @@ pub fn main(gctx: &mut GlobalContext) -> CliResult {
.map(String::as_str)
== Some("help")
{
// Don't let config errors get in the way of parsing arguments
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
print_zhelp(gctx);
} else if expanded_args.flag("version") {
// Don't let config errors get in the way of parsing arguments
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
let version = get_version_string(is_verbose);
drop_print!(gctx, "{}", version);
} else if let Some(code) = expanded_args.get_one::<String>("explain") {
// Don't let config errors get in the way of parsing arguments
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
let mut procss = gctx.load_global_rustc(None)?.process();
procss.arg("--explain").arg(code).exec()?;
} else if expanded_args.flag("list") {
// Don't let config errors get in the way of parsing arguments
let _ = config_configure(gctx, &expanded_args, None, global_args, None);
print_list(gctx, is_verbose);
} else {
let (cmd, subcommand_args) = match expanded_args.subcommand() {
Expand Down

0 comments on commit a9b82ca

Please sign in to comment.