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

feat: Enable shell completion #919

Merged
merged 17 commits into from
Jul 11, 2020
Prev Previous commit
Next Next commit
black
  • Loading branch information
lukasheinrich committed Jul 11, 2020
commit 052f80f0bd62e72404e5fc56f5af7d102bdeb27a
2 changes: 1 addition & 1 deletion src/pyhf/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def pyhf():

pyhf.add_command(patchset.cli)

pyhf.add_command(complete.cli)
pyhf.add_command(complete.cli)
10 changes: 6 additions & 4 deletions src/pyhf/cli/complete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import click

try:
import click_completion

click_completion.init()

@click.command(help='Generate shell completion code.', name='completions')
Expand All @@ -12,14 +14,14 @@
def cli(shell):
click.echo(click_completion.core.get_code(shell))


except ImportError:

@click.command(help='Generate shell completion code.', name='completions')
@click.argument(
'shell', default = None
)
@click.argument('shell', default=None)
def cli(shell):
click.secho(
'This requires the click_completion module.\n'
'You can install it with the shellcomplete extra:\n'
'python -m pip install pyhf[shellcomplete]'
)
)