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

Support click >= 8. #31

Merged
merged 1 commit into from Jun 26, 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
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