Skip to content

disable Force color over no color #8183

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

Closed

Conversation

Aditya-PS-05
Copy link
Contributor

closes #8173

Comment on lines 79 to 84
} else if matches!(
args.color,
ColorChoice::Always | ColorChoice::Never | ColorChoice::Auto
) {
// If `--color` is passed explicitly, use the value of `args.color` directly.
args.color
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this always match since the default is "auto" at the clap-level?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yupp, But I thought if --color is passed explicitly, we can use the value of args.color directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, when I tested the expected result was coming for all three separate cases. Means for FORCE_COLOR and --color and with sub arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this always match since the default is "auto" at the clap-level?

Done purposely, as when the user does not anything (neither the environment variables nor the --color), then I wanted the auto property. As If --color is given, it doesn't matter the value, we can always use them.

@samypr100
Copy link
Collaborator

samypr100 commented Oct 14, 2024

Unless I'm missing something, I believe this changes standard behavior since env var should still take priority over cli when honoring the order of no color > force color | force cli color > auto

For example, if you have NO_COLOR set and pass --color always as well, NO_COLOR should take precedence.

@zanieb
Copy link
Member

zanieb commented Oct 14, 2024

if you have NO_COLOR set and pass --color always as well, NO_COLOR should take precedence.

Should it? Honestly not sure.

@samypr100
Copy link
Collaborator

samypr100 commented Oct 14, 2024

if you have NO_COLOR set and pass --color always as well, NO_COLOR should take precedence.

Should it? Honestly not sure.

Fair, I was considering CI scenarios when I said this. Wouldn't this be a breaking if changed?

@charliermarsh
Copy link
Member

The docs (https://no-color.org/) at least state that "per-instance command-line arguments should override the NO_COLOR environment variable".

@samypr100
Copy link
Collaborator

The docs (https://no-color.org/) at least state that "per-instance command-line arguments should override the NO_COLOR environment variable".

Does the same apply for FORCE_COLOR? Or CLICOLOR_FORCE?

@samypr100
Copy link
Collaborator

samypr100 commented Oct 14, 2024

The docs (https://no-color.org/) at least state that "per-instance command-line arguments should override the NO_COLOR environment variable".

Does the same apply for FORCE_COLOR? Or CLICOLOR_FORCE?

Sounds like it does at least for CLICOLOR_FORCE, https://bixense.com/clicolors/
FORCE_COLOR doesn't say.

I've likely been using it wrong 😆

To me, its a bit vague since the relationship between NO_COLOR and FORCE_COLOR and CLICOLOR_FORCE in this scenario is not well defined in any of the standards from what I can see.

Sounds like uv should follow this then?

  1. Explicit CLI --color never / --color always takes precedence over the env vars.
  2. Env vars then kick-in, NO_COLOR > FORCE_COLOR | CLICOLOR_FORCE
  3. Auto Detection

What about an explicit --color auto? It's not clear which one would apply in the presence of the env vars being set.

@charliermarsh
Copy link
Member

Yeah, agree with this @samypr100:

  • Explicit CLI --color never / --color always takes precedence over the env vars.
  • Env vars then kick-in, NO_COLOR > FORCE_COLOR | CLICOLOR_FORCE
  • Auto Detection

I think --color=auto should also override the env vars (https://bixense.com/clicolors/ shows an example of that, arguably).

@charliermarsh
Copy link
Member

@Aditya-PS-05 - Do you plan to pursue the follow-up changes mentioned here?

@Aditya-PS-05
Copy link
Contributor Author

Yeah, agree with this @samypr100:

* Explicit CLI --color never / --color always takes precedence over the env vars.

* Env vars then kick-in, NO_COLOR > FORCE_COLOR | CLICOLOR_FORCE

* Auto Detection

I think --color=auto should also override the env vars (https://bixense.com/clicolors/ shows an example of that, arguably).

@charliermarsh
I am making this change following your instructions.

@Aditya-PS-05
Copy link
Contributor Author

All the required changes are done in the pr #8215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FORCE_COLOR wins over --color never
4 participants