From 6cc482ceebf78c9ab4244e3b5bff33a17d4f26fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Mee=C3=9Fen?= <52298176+fmssn@users.noreply.github.com> Date: Fri, 6 Oct 2023 16:59:45 +0200 Subject: [PATCH 1/4] Add quiet option to pipenv shell. --quiet now hides the message "Launching subshell in virtual environment..." --- pipenv/cli/command.py | 5 +++++ pipenv/routines/shell.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 5e7d88a7..a6eadd2c 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -364,6 +364,9 @@ 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 @@ -373,6 +376,7 @@ def shell( fancy=False, shell_args=None, anyway=False, + quiet=False ): """Spawns a shell within the virtualenv.""" from pipenv.routines.shell import do_shell @@ -399,6 +403,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..f031beee 100644 --- a/pipenv/routines/shell.py +++ b/pipenv/routines/shell.py @@ -9,7 +9,7 @@ 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 +25,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, From cf7662c13ddbd8f314bd4f09de64e06480b22085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Mee=C3=9Fen?= <52298176+fmssn@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:09:50 +0200 Subject: [PATCH 2/4] fix formatting --- pipenv/cli/command.py | 10 ++-------- pipenv/routines/shell.py | 4 +++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pipenv/cli/command.py b/pipenv/cli/command.py index 6f658f10..0357dbf9 100644 --- a/pipenv/cli/command.py +++ b/pipenv/cli/command.py @@ -371,13 +371,7 @@ def lock(ctx, state, **kwargs): @pypi_mirror_option @python_option @pass_state -def shell( - state, - fancy=False, - shell_args=None, - anyway=False, - quiet=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 @@ -403,7 +397,7 @@ def shell( fancy=fancy, shell_args=shell_args, pypi_mirror=state.pypi_mirror, - quiet=quiet + quiet=quiet, ) diff --git a/pipenv/routines/shell.py b/pipenv/routines/shell.py index f031beee..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, quiet=False): +def do_shell( + project, python=False, fancy=False, shell_args=None, pypi_mirror=None, quiet=False +): # Ensure that virtualenv is available. ensure_project( project, From 0c211342a6e41efeb7cff9af50eb79a753ba5979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Mee=C3=9Fen?= <52298176+fmssn@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:34:31 +0200 Subject: [PATCH 3/4] add news fragment --- news/5966.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5966.feature.rst diff --git a/news/5966.feature.rst b/news/5966.feature.rst new file mode 100644 index 00000000..732414b3 --- /dev/null +++ b/news/5966.feature.rst @@ -0,0 +1 @@ +Add quiet option to pipenv shell, hiding "Launching subshell in virtual environment..." \ No newline at end of file From 9c1344efcdc0c51df290a0976caab8b78ae5a1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Mee=C3=9Fen?= <52298176+fmssn@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:40:12 +0200 Subject: [PATCH 4/4] add new line for linter --- news/5966.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/5966.feature.rst b/news/5966.feature.rst index 732414b3..e1d92c27 100644 --- a/news/5966.feature.rst +++ b/news/5966.feature.rst @@ -1 +1 @@ -Add quiet option to pipenv shell, hiding "Launching subshell in virtual environment..." \ No newline at end of file +Add quiet option to pipenv shell, hiding "Launching subshell in virtual environment..."