Skip to content

Commit

Permalink
Merge pull request #2041 from lyft/allow-force-enabling-or-disabling-…
Browse files Browse the repository at this point in the history
…colorized-output

Allow force-enabling or force-disabling colorized output
  • Loading branch information
chrysle authored Jan 4, 2024
2 parents 129d099 + 010db60 commit c21525b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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 @@ def _determine_linesep(
)
@click.pass_context
@options.version
@options.color
@options.verbose
@options.quiet
@options.dry_run
Expand Down Expand Up @@ -118,6 +119,7 @@ def _determine_linesep(
@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 @@ def cli(
Compiles requirements.txt from requirements.in, pyproject.toml, setup.cfg,
or setup.py specs.
"""
if color is not None:
ctx.color = color
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

0 comments on commit c21525b

Please sign in to comment.