Skip to content

Commit

Permalink
Support click >= 8.
Browse files Browse the repository at this point in the history
Click 8 does no longer provide raw_input and has overhauled its shell
completion code. This patch provides the necessary adjustments.
  • Loading branch information
gouttegd authored and clarkperkins committed Jun 26, 2021
1 parent c098de2 commit fc53c98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 1 addition & 2 deletions click_shell/_cmd.py
Expand Up @@ -9,9 +9,8 @@
from cmd import Cmd

import click
from click._compat import raw_input as get_input

from click_shell._compat import readline
from click_shell._compat import readline, get_input


class ClickCmd(Cmd, object):
Expand Down
16 changes: 15 additions & 1 deletion click_shell/_compat.py
Expand Up @@ -19,6 +19,14 @@
except ImportError:
readline = None

try:
from click._compat import raw_input as get_input
except ImportError:
# If click._compat does not provide raw_input, it means we're
# dealing with click >= 8, which means we're under Python 3,
# so we can just use the standard input function.
get_input = input


def get_method_type(func, obj):
if PY2:
Expand All @@ -33,7 +41,13 @@ def get_method_type(func, obj):
except ImportError:

import click
from click._bashcomplete import resolve_ctx
try:
from click._bashcomplete import resolve_ctx
except ImportError:
from click.shell_completion import _resolve_context

def resolve_ctx(cli, prog_name, args):
return _resolve_context(cli, {}, prog_name, args)

def get_choices(cli, prog_name, args, incomplete):
"""
Expand Down

0 comments on commit fc53c98

Please sign in to comment.