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

Replace click-completion with click's own completion code #4849

Merged
merged 1 commit into from Nov 9, 2021
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
10 changes: 7 additions & 3 deletions docs/advanced.rst
Expand Up @@ -568,11 +568,15 @@ A 3rd party plugin, `tox-pipenv`_ is also available to use Pipenv natively with

To enable completion in fish, add this to your configuration::

eval (pipenv --completion)
eval (env _PIPENV_COMPLETE=fish_source pipenv)

Alternatively, with bash or zsh, add this to your configuration::
Alternatively, with zsh, add this to your configuration::

eval "$(pipenv --completion)"
eval "$(_PIPENV_COMPLETE=zsh_source pipenv)"

Alternatively, with bash, add this to your configuration::

eval "$(_PIPENV_COMPLETE=bash_source pipenv)"

Magic shell completions are now enabled!

Expand Down
1 change: 1 addition & 0 deletions news/4786.feature.rst
@@ -0,0 +1 @@
Replace ``click-completion`` with ``click``'s own completion implementation.
27 changes: 0 additions & 27 deletions pipenv/cli/command.py
Expand Up @@ -12,16 +12,12 @@
from pipenv.exceptions import PipenvOptionsError
from pipenv.patched import crayons
from pipenv.utils import subprocess_run
from pipenv.vendor import click_completion
from pipenv.vendor.click import (
Choice, argument, echo, edit, group, option, pass_context, secho, types,
version_option
)


# Enable shell completion.
click_completion.init()

subcommand_context = CONTEXT_SETTINGS.copy()
subcommand_context.update({
"ignore_unknown_options": True,
Expand All @@ -38,12 +34,6 @@
@option("--envs", is_flag=True, default=False, help="Output Environment Variable options.")
@option("--rm", is_flag=True, default=False, help="Remove the virtualenv.")
@option("--bare", is_flag=True, default=False, help="Minimal output.")
@option(
"--completion",
is_flag=True,
default=False,
help="Output completion (to be executed by the shell).",
)
@option("--man", is_flag=True, default=False, help="Display manpage.")
@option(
"--support",
Expand All @@ -63,29 +53,12 @@ def cli(
envs=False,
rm=False,
bare=False,
completion=False,
man=False,
support=None,
help=False,
site_packages=None,
**kwargs
):
# Handle this ASAP to make shell startup fast.
if completion:
from .. import shells

try:
shell = shells.detect_info(state.project)[0]
except shells.ShellDetectionFailure:
echo(
"Fail to detect shell. Please provide the {} environment "
"variable.".format(crayons.normal("PIPENV_SHELL", bold=True)),
err=True,
)
ctx.abort()
print(click_completion.get_code(shell=shell, prog_name="pipenv"))
return 0

from ..core import (
cleanup_virtualenv, do_clear, do_py, do_where, ensure_project,
format_help, system_which, warn_in_virtualenv
Expand Down
5 changes: 1 addition & 4 deletions pipenv/core.py
Expand Up @@ -12,8 +12,6 @@
import pipfile
import vistir

from click_completion import init as init_completion

from pipenv import environments, exceptions, pep508checker, progress
from pipenv._compat import decode_for_output, fix_utf8
from pipenv.patched import crayons
Expand Down Expand Up @@ -66,8 +64,7 @@
INSTALL_LABEL = " "
INSTALL_LABEL2 = " "
STARTING_LABEL = " "
# Enable shell completion.
init_completion()

# Disable colors, for the color blind and others who do not prefer colors.
if environments.PIPENV_COLORBLIND:
crayons.disable()
Expand Down
21 changes: 0 additions & 21 deletions pipenv/vendor/click_completion/LICENSE

This file was deleted.

88 changes: 0 additions & 88 deletions pipenv/vendor/click_completion/__init__.py

This file was deleted.

12 changes: 0 additions & 12 deletions pipenv/vendor/click_completion/bash.j2

This file was deleted.