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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
)
@click.pass_context
@options.version
@options.color
@options.verbose
@options.quiet
@options.dry_run
Expand Down Expand Up @@ -118,6 +119,7 @@
@options.only_build_deps
def cli(
ctx: click.Context,
color: bool | None,
verbose: int,
quiet: int,
dry_run: bool,
Expand Down Expand Up @@ -165,6 +167,8 @@
Compiles requirements.txt from requirements.in, pyproject.toml, setup.cfg,
or setup.py specs.
"""
if color is not None:
ctx.color = color

Check warning on line 171 in piptools/scripts/compile.py

View check run for this annotation

Codecov / codecov/patch

piptools/scripts/compile.py#L171

Added line #L171 was not covered by tests
log.verbosity = verbose - quiet

if all_build_deps and build_deps_targets:
Expand Down
6 changes: 6 additions & 0 deletions piptools/scripts/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def _get_default_option(option_name: str) -> Any:

version = click.version_option(package_name="pip-tools")

color = click.option(
"--color/--no-color",
default=None,
help="Force output to be colorized or not, instead of auto-detecting color support",
)

verbose = click.option(
"-v",
"--verbose",
Expand Down