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

fix(completions): convert to click@8 and update docs #369

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ recommended setup ``HASS_SERVER`` and ``HASS_TOKEN`` environment variables.
$ export HASS_SERVER=https://homeassistant.local:8123
$ export HASS_TOKEN=<secret>

Once that is enabled and you are using either ``zsh`` or ``bash`` run
the following to enable autocompletion for ``hass-cli`` commands.
Once that is enabled, run one of the following commands to enable
autocompletion for ``hass-cli`` commands.

.. code:: bash

$ source <(hass-cli completion zsh)

$ source <(_HASS_CLI_COMPLETE=bash_source hass-cli) # for bash
$ source <(_HASS_CLI_COMPLETE=zsh_source hass-cli) # for zsh
$ eval (_HASS_CLI_COMPLETE=fish_source hass-cli) # for fish

Usage
=======
Expand Down Expand Up @@ -492,7 +493,6 @@ Help

Commands:
area Get info and operate on areas from Home Assistant...
completion Output shell completion code for the specified shell (bash or...
config Get configuration from a Home Assistant instance.
device Get info and operate on devices from Home Assistant...
discover Discovery for the local network.
Expand Down
2 changes: 1 addition & 1 deletion homeassistant_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def _default_token() -> Optional[str]:
'--table-format',
default='plain',
help="Which table format to use.",
autocompletion=autocompletion.table_formats,
shell_complete=autocompletion.table_formats,
)
@click.option(
'--sort-by',
Expand Down
4 changes: 2 additions & 2 deletions homeassistant_cli/plugins/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create(ctx, names):
'names',
nargs=-1,
required=True,
autocompletion=autocompletion.areas, # type: ignore
shell_complete=autocompletion.areas, # type: ignore
)
@pass_context
def delete(ctx, names):
Expand Down Expand Up @@ -114,7 +114,7 @@ def delete(ctx, names):
@click.argument(
'oldname',
required=True,
autocompletion=autocompletion.areas, # type: ignore
shell_complete=autocompletion.areas, # type: ignore
)
@click.argument('newname', required=True)
@pass_context
Expand Down
2 changes: 1 addition & 1 deletion homeassistant_cli/plugins/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def listcmd(ctx: Configuration, devicefilter: str):
@click.argument(
'area_id_or_name',
required=True,
autocompletion=autocompletion.areas, # type: ignore
shell_complete=autocompletion.areas, # type: ignore
)
@click.argument('names', nargs=-1, required=False)
@click.option(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant_cli/plugins/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def listcmd(ctx: Configuration, entityfilter: str):
@click.argument(
'oldid',
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@click.option('--name', required=False)
@click.argument(
'newid',
required=False,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@pass_context
def rename(ctx, oldid, newid, name):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant_cli/plugins/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def cli(ctx):
@click.argument(
'event',
required=True,
autocompletion=autocompletion.events, # type: ignore
shell_complete=autocompletion.events, # type: ignore
)
@click.option(
'--json',
Expand Down
2 changes: 1 addition & 1 deletion homeassistant_cli/plugins/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@click.argument(
'entity',
required=False,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@click.option(
'--service', default='openstreetmap', type=click.Choice(SERVICE.keys())
Expand Down
6 changes: 3 additions & 3 deletions homeassistant_cli/plugins/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _report(ctx, cmd, method, response) -> None:

@cli.command()
@click.argument(
'method', autocompletion=autocompletion.api_methods # type: ignore
'method', shell_complete=autocompletion.api_methods # type: ignore
)
@pass_context
def get(ctx: Configuration, method):
Expand All @@ -54,7 +54,7 @@ def get(ctx: Configuration, method):

@cli.command()
@click.argument(
'method', autocompletion=autocompletion.api_methods # type: ignore
'method', shell_complete=autocompletion.api_methods # type: ignore
)
@click.option('--json')
@pass_context
Expand All @@ -72,7 +72,7 @@ def post(ctx: Configuration, method, json):

@cli.command("ws")
@click.argument(
'wstype', autocompletion=autocompletion.wsapi_methods # type: ignore
'wstype', shell_complete=autocompletion.wsapi_methods # type: ignore
)
@click.option('--json')
@pass_context
Expand Down
2 changes: 1 addition & 1 deletion homeassistant_cli/plugins/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def list_cmd(ctx: Configuration, servicefilter):
@click.argument(
'service',
required=True,
autocompletion=autocompletion.services, # type: ignore
shell_complete=autocompletion.services, # type: ignore
)
@click.option(
'--arguments', help="Comma separated key/value pairs to use as arguments."
Expand Down
14 changes: 7 additions & 7 deletions homeassistant_cli/plugins/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def cli(ctx):
@click.argument(
'entity',
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@pass_context
def get(ctx: Configuration, entity):
Expand All @@ -50,7 +50,7 @@ def get(ctx: Configuration, entity):
@click.argument(
'entity',
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@pass_context
def delete(ctx: Configuration, entity):
Expand Down Expand Up @@ -95,7 +95,7 @@ def list(ctx, entityfilter):
@click.argument(
'entity',
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@click.argument('newstate', required=False)
@click.option(
Expand Down Expand Up @@ -207,7 +207,7 @@ def _homeassistant_cmd(ctx: Configuration, entities, cmd, action):
'entities',
nargs=-1,
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@pass_context
def toggle(ctx: Configuration, entities):
Expand All @@ -221,7 +221,7 @@ def toggle(ctx: Configuration, entities):
'entities',
nargs=-1,
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@pass_context
def off_cmd(ctx: Configuration, entities):
Expand All @@ -235,7 +235,7 @@ def off_cmd(ctx: Configuration, entities):
'entities',
nargs=-1,
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@pass_context
def on_cmd(ctx: Configuration, entities):
Expand All @@ -249,7 +249,7 @@ def on_cmd(ctx: Configuration, entities):
'entities',
nargs=-1,
required=True,
autocompletion=autocompletion.entities, # type: ignore
shell_complete=autocompletion.entities, # type: ignore
)
@click.option(
'--since',
Expand Down