Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/6182.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove click.echo from pipenv/cli
4 changes: 1 addition & 3 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,8 @@ def cli(
pypi_mirror=state.pypi_mirror,
clear=state.clear,
)
# Check this again before exiting for empty ``pipenv`` command.
elif ctx.invoked_subcommand is None:
# Display help to user, if no commands were passed.
print(format_help(ctx.get_help()))
console.print(format_help(ctx.get_help()))


@cli.command(
Expand Down
10 changes: 2 additions & 8 deletions pipenv/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import re

from pipenv.project import Project
from pipenv.utils import err
from pipenv.utils import console, err
from pipenv.utils.internet import is_valid_url
from pipenv.vendor.click import (
BadArgumentUsage,
BadParameter,
Group,
Option,
argument,
echo,
make_pass_decorator,
option,
)
Expand All @@ -33,12 +32,7 @@ def get_help_option(self, ctx):

def show_help(ctx, param, value):
if value and not ctx.resilient_parsing:
if not ctx.invoked_subcommand:
# legit main help
echo(format_help(ctx.get_help()))
else:
# legit sub-command help
echo(ctx.get_help(), color=ctx.color)
console.print(format_help(ctx.get_help()))
ctx.exit()

return Option(
Expand Down
3 changes: 1 addition & 2 deletions pipenv/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
from pipenv.patched.pip._vendor.rich.console import Console

logging.basicConfig(level=logging.INFO)

console = Console()
console = Console(highlight=False)
err = Console(stderr=True)
55 changes: 22 additions & 33 deletions pipenv/utils/display.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
from pipenv.vendor import click


def format_help(help):
"""Formats the help string."""
help = help.replace("Options:", str(click.style("Options:", bold=True)))
help = help.replace(
"Usage: pipenv", str("Usage: {}".format(click.style("pipenv", bold=True)))
)
help = help.replace(" check", str(click.style(" check", fg="red", bold=True)))
help = help.replace(" clean", str(click.style(" clean", fg="red", bold=True)))
help = help.replace(" graph", str(click.style(" graph", fg="red", bold=True)))
help = help.replace(
" install", str(click.style(" install", fg="magenta", bold=True))
)
help = help.replace(" lock", str(click.style(" lock", fg="green", bold=True)))
help = help.replace(" open", str(click.style(" open", fg="red", bold=True)))
help = help.replace(" run", str(click.style(" run", fg="yellow", bold=True)))
help = help.replace(" shell", str(click.style(" shell", fg="yellow", bold=True)))
help = help.replace(
" scripts", str(click.style(" scripts", fg="yellow", bold=True))
)
help = help.replace(" sync", str(click.style(" sync", fg="green", bold=True)))
help = help.replace(
" uninstall", str(click.style(" uninstall", fg="magenta", bold=True))
)
help = help.replace(" update", str(click.style(" update", fg="green", bold=True)))
help = help.replace("Options:", "[bold]Options:[/bold]")
help = help.replace("Usage: pipenv", "Usage: [bold]pipenv[/bold]")
help = help.replace(" check", "[bold red] check[/red bold]")
help = help.replace(" clean", "[bold red] clean[/red bold]")
help = help.replace(" graph", "[bold red] graph[/red bold]")
help = help.replace(" install", "[bold magenta] install[/magenta bold]")
help = help.replace(" lock", "[bold green] lock[/green bold]")
help = help.replace(" open", "[bold red] open[/red bold]")
help = help.replace(" run", "[bold yellow] run[/yellow bold]")
help = help.replace(" shell", "[bold yellow] shell[/yellow bold]")
help = help.replace(" scripts", "[bold yellow] scripts[/yellow bold]")
help = help.replace(" sync", "[bold green] sync[/green bold]")
help = help.replace(" uninstall", "[bold magenta] uninstall[/magenta bold]")
help = help.replace(" update", "[bold green] update[/green bold]")
additional_help = """
Usage Examples:
Create a new project using Python 3.7, specifically:
Expand Down Expand Up @@ -52,14 +41,14 @@ def format_help(help):
$ {}

Commands:""".format(
click.style("pipenv --python 3.7", fg="yellow"),
click.style("pipenv --rm", fg="yellow"),
click.style("pipenv install --dev", fg="yellow"),
click.style("pipenv lock --pre", fg="yellow"),
click.style("pipenv graph", fg="yellow"),
click.style("pipenv check", fg="yellow"),
click.style("pipenv install -e .", fg="yellow"),
click.style("pipenv run pip freeze", fg="yellow"),
"[yellow]pipenv --python 3.7[/yellow]",
"[yellow]pipenv --rm[/yellow]",
"[yellow]pipenv install --dev[/yellow]",
"[yellow]pipenv lock --pre[/yellow]",
"[yellow]pipenv graph[/yellow]",
"[yellow]pipenv check[/yellow]",
"[yellow]pipenv install -e .[/yellow]",
"[yellow]pipenv run pip freeze[/yellow]",
)
help = help.replace("Commands:", additional_help)
return help