Skip to content

Commit

Permalink
fix for prompt-toolkit breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Jul 29, 2018
1 parent 85895f2 commit 6255940
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions click_repl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
from .exceptions import InternalCommandException, ExitReplException # noqa


PY2 = sys.version_info[0] == 2

if PY2:
text_type = unicode
else:
text_type = str


__version__ = '0.1.4'

_internal_commands = dict()
Expand Down Expand Up @@ -100,18 +108,18 @@ def get_completions(self, document, complete_event=None):
if isinstance(param, click.Option):
for options in (param.opts, param.secondary_opts):
for o in options:
choices.append(Completion(o, -len(incomplete),
choices.append(Completion(text_type(o), -len(incomplete),
display_meta=param.help))
elif isinstance(param, click.Argument):
if isinstance(param.type, click.Choice):
for choice in param.type.choices:
choices.append(Completion(choice, -len(incomplete)))
choices.append(Completion(text_type(choice), -len(incomplete)))

if isinstance(ctx.command, click.MultiCommand):
for name in ctx.command.list_commands(ctx):
command = ctx.command.get_command(ctx, name)
choices.append(Completion(
name,
text_type(name),
-len(incomplete),
display_meta=getattr(command, 'short_help')
))
Expand Down

0 comments on commit 6255940

Please sign in to comment.