Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env variable to configure locked, frozen and color #726

Merged
merged 8 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use clap_complete;
use clap_verbosity_flag::Verbosity;
use miette::IntoDiagnostic;
use std::io::IsTerminal;
use std::{env, io::IsTerminal};
use tracing_subscriber::{filter::LevelFilter, util::SubscriberInitExt, EnvFilter};

pub mod add;
Expand Down Expand Up @@ -115,6 +115,16 @@ pub async fn execute() -> miette::Result<()> {
)
}))?;

// Honor FORCE_COLOR and NO_COLOR environment variables.
// Those take precedence over the CLI flag and PIXI_COLOR
let use_colors = match env::var("FORCE_COLOR") {
Ok(_) => true,
Err(_) => match env::var("NO_COLOR") {
Ok(_) => false,
Err(_) => use_colors,
},
};

hadim marked this conversation as resolved.
Show resolved Hide resolved
// Enable disable colors for the colors crate
console::set_colors_enabled(use_colors);
console::set_colors_enabled_stderr(use_colors);
Expand Down