Skip to content

Commit

Permalink
click8: click._bashcomplete -> click.shell_completion
Browse files Browse the repository at this point in the history
  • Loading branch information
graham33 committed Aug 28, 2021
1 parent 7127994 commit 856a954
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions typer/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Optional, Tuple

import click
import click._bashcomplete
import click.shell_completion

from .models import ParamMeta
from .params import Option
Expand Down Expand Up @@ -311,7 +311,7 @@ def do_bash_complete(cli: click.Command, prog_name: str) -> bool:
except IndexError:
incomplete = ""

for item in click._bashcomplete.get_choices(cli, prog_name, args, incomplete):
for item in click.shell_completion.get_choices(cli, prog_name, args, incomplete):
click.echo(item[0])
return True

Expand All @@ -335,7 +335,7 @@ def escape(s: str) -> str:
)

res = []
for item, help in click._bashcomplete.get_choices(cli, prog_name, args, incomplete):
for item, help in click.shell_completion.get_choices(cli, prog_name, args, incomplete):
if help:
res.append(f'"{escape(item)}":"{escape(help)}"')
else:
Expand All @@ -359,7 +359,7 @@ def do_fish_complete(cli: click.Command, prog_name: str) -> bool:
else:
incomplete = ""
show_args = []
for item, help in click._bashcomplete.get_choices(cli, prog_name, args, incomplete):
for item, help in click.shell_completion.get_choices(cli, prog_name, args, incomplete):
if help:
formatted_help = re.sub(r"\s", " ", help)
show_args.append(f"{item}\t{formatted_help}")
Expand All @@ -384,7 +384,7 @@ def do_powershell_complete(cli: click.Command, prog_name: str) -> bool:
incomplete = os.getenv("_TYPER_COMPLETE_WORD_TO_COMPLETE", "")
cwords = click.parser.split_arg_string(completion_args)
args = cwords[1:]
for item, help in click._bashcomplete.get_choices(cli, prog_name, args, incomplete):
for item, help in click.shell_completion.get_choices(cli, prog_name, args, incomplete):
click.echo(f"{item}:::{help or ' '}")

return True
Expand Down Expand Up @@ -412,7 +412,7 @@ def do_shell_complete(*, cli: click.Command, prog_name: str, shell: str) -> bool


def get_completion_script(*, prog_name: str, complete_var: str, shell: str) -> str:
cf_name = click._bashcomplete._invalid_ident_char_re.sub(
cf_name = click.shell_completion._invalid_ident_char_re.sub(
"", prog_name.replace("-", "_")
)
script = _completion_scripts.get(shell)
Expand Down Expand Up @@ -463,7 +463,7 @@ def testing_handle_shell_complete(
return result

if testing:
click._bashcomplete.bashcomplete = testing_handle_shell_complete
click.shell_completion.bashcomplete = testing_handle_shell_complete
else:
click._bashcomplete.bashcomplete = handle_shell_complete
click.shell_completion.bashcomplete = handle_shell_complete
_click_patched = True

0 comments on commit 856a954

Please sign in to comment.