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

Allow force-enabling or force-disabling colorized output #2041

Conversation

aneeshusa
Copy link
Contributor

@aneeshusa aneeshusa commented Jan 3, 2024

click allows emitted colored text via click.style,
which is used by pip-compile to emit colorized e.g. comments to stderr.
click uses auto-detection to only enable colors when writing to a TTY.

At Lyft, we operate pip-compile as a service:
pip-compile invocations are forwarded to a set of remote machines,
which leverage a shared cache for much faster compiles.
However, they run pip-compile as a subprocess without a TTY attached
meaning the output we stream back to the user is not colorized.

Therefore, add a --color and matching --no-color argument
to force-enable as well as force-disable color
(the default remains click's auto-detection).
This could also be used for e.g. running pip-compile in CI.

AFAIK pip-sync does not emit colored output,
so I did not add the --color/--no-color options there.

Contributor checklist
  • Included tests for the changes.
  • PR title is short, clear, and ready to be included in the user-facing changelog.
Maintainer checklist
  • Verified one of these labels is present: backwards incompatible, feature, enhancement, deprecation, bug, dependency, docs or skip-changelog as they determine changelog listing.
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

`click` allows emitted colored text via `click.style`,
which is used by pip-compile to emit colorized e.g. comments to stderr.
click uses auto-detection to only enable colors when writing to a TTY.

At Lyft, we operate pip-compile as a service:
pip-compile invocations are forwarded to a set of remote machines,
which leverage a shared cache for much faster compiles.
However, they run pip-compile as a subprocess without a TTY attached
meaning the output we stream back to the user is not colorized.

Therefore, add a `--color` and matching `--no-color` argument
to force-enable as well as force-disable color
(the default remains click's auto-detection).
This could also be used for e.g. running pip-compile in CI.

AFAIK pip-sync does not emit colored output,
so I did not add the `--color/--no-color` options there.
@aneeshusa aneeshusa force-pushed the allow-force-enabling-or-disabling-colorized-output branch from b96be7d to 010db60 Compare January 3, 2024 21:50
Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

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

Thanks!

@chrysle chrysle enabled auto-merge January 4, 2024 16:06
@chrysle chrysle added logging Related to log or console output feature Request for a new feature cli Related to command line interface things labels Jan 4, 2024
@chrysle chrysle added this pull request to the merge queue Jan 4, 2024
Merged via the queue into jazzband:main with commit c21525b Jan 4, 2024
34 of 36 checks passed
@aneeshusa
Copy link
Contributor Author

Thank you for taking a look @chrysle!

@atugushev atugushev added this to the 7.4.0 milestone Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to command line interface things feature Request for a new feature logging Related to log or console output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants