diff --git a/news/5966.feature.rst b/news/5966.feature.rst new file mode 100644 index 00000000..e1d92c27 --- /dev/null +++ b/news/5966.feature.rst @@ -0,0 +1 @@ +Add quiet option to pipenv shell, hiding "Launching subshell in virtual environment..." diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index fb4ee058..0357dbf9 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -364,16 +364,14 @@ def lock(ctx, state, **kwargs): default=False, help="Always spawn a sub-shell, even if one is already spawned.", ) +@option( + "--quiet", is_flag=True, help="Quiet standard output, except vulnerability report." +) @argument("shell_args", nargs=-1) @pypi_mirror_option @python_option @pass_state -def shell( - state, - fancy=False, - shell_args=None, - anyway=False, -): +def shell(state, fancy=False, shell_args=None, anyway=False, quiet=False): """Spawns a shell within the virtualenv.""" from pipenv.routines.shell import do_shell @@ -399,6 +397,7 @@ def shell( fancy=fancy, shell_args=shell_args, pypi_mirror=state.pypi_mirror, + quiet=quiet, ) diff --git a/pipenv/routines/shell.py b/pipenv/routines/shell.py index 0d3089e8..a4a4df62 100644 --- a/pipenv/routines/shell.py +++ b/pipenv/routines/shell.py @@ -9,7 +9,9 @@ from pipenv.utils.shell import cmd_list_to_shell, system_which from pipenv.vendor import click -def do_shell(project, python=False, fancy=False, shell_args=None, pypi_mirror=None): +def do_shell( + project, python=False, fancy=False, shell_args=None, pypi_mirror=None, quiet=False +): # Ensure that virtualenv is available. ensure_project( project, @@ -25,7 +27,8 @@ def do_shell(project, python=False, fancy=False, shell_args=None, pypi_mirror=No from pipenv.shells import choose_shell shell = choose_shell(project) - click.echo("Launching subshell in virtual environment...", err=True) + if not quiet: + click.echo("Launching subshell in virtual environment...", err=True) fork_args = ( project.virtualenv_location,