Fix NO_COLOR convention regression#886
Draft
nel wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NO_COLORis a de-facto convention for disabling ANSI color output. The convention is presence-based: ifNO_COLORis present and non-empty, color should be disabled regardless of the specific value.Reference:
oha used to accept this convention, but since the
--no-colorclap/env wiring change it now parsesNO_COLORas a strict boolean. As a result, the common formNO_COLOR=1now fails during argument parsing:This PR restores convention-compatible
NO_COLORhandling.Behavior
After this change:
NO_COLORdoes not disable colorNO_COLOR=does not disable colorNO_COLOR, includingNO_COLOR=1, disables colorNO_COLOR=truedisables colorNO_COLOR=falsedisables color--no-colorcontinues to workCompatibility note
Restoring the NO_COLOR convention means this is technically a behavior change for
NO_COLOR=false.With the recent strict boolean parsing,
NO_COLOR=falsemeant “do not disable color”. With convention-compatible parsing,NO_COLOR=falsedisables color because the variable is present and non-empty.Users who want color should unset
NO_COLORor set it to an empty value.Tests
Added coverage for:
NO_COLOR=1NO_COLOR=NO_COLOR=trueNO_COLOR=false--no-colorRan locally:
cargo test no_color -- --nocapturecargo fmt --all --checkcargo clippy --all-targets -- -D warnings