mirror of https://github.com/craigerl/aprsd.git
Removed the requirement on click-completion
This was an older way to do command line completion with click. Now we use the built in completion with click itself. click.shell_completion
This commit is contained in:
parent
f02db20c3e
commit
992485e9c7
|
@ -1,5 +1,5 @@
|
||||||
import click
|
import click
|
||||||
import click_completion
|
import click.shell_completion
|
||||||
|
|
||||||
from aprsd.main import cli
|
from aprsd.main import cli
|
||||||
|
|
||||||
|
@ -7,30 +7,16 @@ from aprsd.main import cli
|
||||||
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||||
|
|
||||||
|
|
||||||
@cli.group(help="Click Completion subcommands", context_settings=CONTEXT_SETTINGS)
|
@cli.command()
|
||||||
@click.pass_context
|
@click.argument("shell", type=click.Choice(list(click.shell_completion._available_shells)))
|
||||||
def completion(ctx):
|
def completion(shell):
|
||||||
pass
|
"""Show the shell completion code"""
|
||||||
|
from click.utils import _detect_program_name
|
||||||
|
|
||||||
|
cls = click.shell_completion.get_completion_class(shell)
|
||||||
# show dumps out the completion code for a particular shell
|
prog_name = _detect_program_name()
|
||||||
@completion.command(help="Show completion code for shell", name="show")
|
complete_var = f"_{prog_name}_COMPLETE".replace("-", "_").upper()
|
||||||
@click.option("-i", "--case-insensitive/--no-case-insensitive", help="Case insensitive completion")
|
print(cls(cli, {}, prog_name, complete_var).source())
|
||||||
@click.argument("shell", required=False, type=click_completion.DocumentedChoice(click_completion.core.shells))
|
print("# Add the following line to your shell configuration file to have aprsd command line completion")
|
||||||
def show(shell, case_insensitive):
|
print("# but remove the leading '#' character.")
|
||||||
"""Show the click-completion-command completion code"""
|
print(f"# eval \"$(aprsd completion {shell})\"")
|
||||||
extra_env = {"_CLICK_COMPLETION_COMMAND_CASE_INSENSITIVE_COMPLETE": "ON"} if case_insensitive else {}
|
|
||||||
click.echo(click_completion.core.get_code(shell, extra_env=extra_env))
|
|
||||||
|
|
||||||
|
|
||||||
# install will install the completion code for a particular shell
|
|
||||||
@completion.command(help="Install completion code for a shell", name="install")
|
|
||||||
@click.option("--append/--overwrite", help="Append the completion code to the file", default=None)
|
|
||||||
@click.option("-i", "--case-insensitive/--no-case-insensitive", help="Case insensitive completion")
|
|
||||||
@click.argument("shell", required=False, type=click_completion.DocumentedChoice(click_completion.core.shells))
|
|
||||||
@click.argument("path", required=False)
|
|
||||||
def install(append, case_insensitive, shell, path):
|
|
||||||
"""Install the click-completion-command completion"""
|
|
||||||
extra_env = {"_CLICK_COMPLETION_COMMAND_CASE_INSENSITIVE_COMPLETE": "ON"} if case_insensitive else {}
|
|
||||||
shell, path = click_completion.core.install(shell=shell, path=path, append=append, extra_env=extra_env)
|
|
||||||
click.echo(f"{shell} completion installed in {path}")
|
|
||||||
|
|
|
@ -24,13 +24,11 @@ import datetime
|
||||||
import importlib.metadata as imp
|
import importlib.metadata as imp
|
||||||
from importlib.metadata import version as metadata_version
|
from importlib.metadata import version as metadata_version
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import click_completion
|
|
||||||
from oslo_config import cfg, generator
|
from oslo_config import cfg, generator
|
||||||
|
|
||||||
# local imports here
|
# local imports here
|
||||||
|
@ -47,18 +45,6 @@ CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
||||||
flask_enabled = False
|
flask_enabled = False
|
||||||
|
|
||||||
|
|
||||||
def custom_startswith(string, incomplete):
|
|
||||||
"""A custom completion match that supports case insensitive matching."""
|
|
||||||
if os.environ.get("_CLICK_COMPLETION_COMMAND_CASE_INSENSITIVE_COMPLETE"):
|
|
||||||
string = string.lower()
|
|
||||||
incomplete = incomplete.lower()
|
|
||||||
return string.startswith(incomplete)
|
|
||||||
|
|
||||||
|
|
||||||
click_completion.core.startswith = custom_startswith
|
|
||||||
click_completion.init()
|
|
||||||
|
|
||||||
|
|
||||||
@click.group(cls=cli_helper.AliasedGroup, context_settings=CONTEXT_SETTINGS)
|
@click.group(cls=cli_helper.AliasedGroup, context_settings=CONTEXT_SETTINGS)
|
||||||
@click.version_option()
|
@click.version_option()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
|
|
|
@ -19,15 +19,15 @@ click==8.1.7 # via black, fixit, moreorless, pip-tools
|
||||||
colorama==0.4.6 # via tox
|
colorama==0.4.6 # via tox
|
||||||
commonmark==0.9.1 # via rich
|
commonmark==0.9.1 # via rich
|
||||||
configargparse==1.7 # via gray
|
configargparse==1.7 # via gray
|
||||||
coverage[toml]==7.4.4 # via pytest-cov
|
coverage[toml]==7.5.0 # via pytest-cov
|
||||||
distlib==0.3.8 # via virtualenv
|
distlib==0.3.8 # via virtualenv
|
||||||
docutils==0.20.1 # via sphinx
|
docutils==0.21.2 # via sphinx
|
||||||
exceptiongroup==1.2.0 # via pytest
|
exceptiongroup==1.2.1 # via pytest
|
||||||
filelock==3.13.4 # via tox, virtualenv
|
filelock==3.13.4 # via tox, virtualenv
|
||||||
fixit==2.1.0 # via gray
|
fixit==2.1.0 # via gray
|
||||||
flake8==7.0.0 # via -r dev-requirements.in, pep8-naming
|
flake8==7.0.0 # via -r dev-requirements.in, pep8-naming
|
||||||
gray==0.14.0 # via -r dev-requirements.in
|
gray==0.14.0 # via -r dev-requirements.in
|
||||||
identify==2.5.35 # via pre-commit
|
identify==2.5.36 # via pre-commit
|
||||||
idna==3.7 # via requests
|
idna==3.7 # via requests
|
||||||
imagesize==1.4.1 # via sphinx
|
imagesize==1.4.1 # via sphinx
|
||||||
iniconfig==2.0.0 # via pytest
|
iniconfig==2.0.0 # via pytest
|
||||||
|
@ -44,8 +44,8 @@ packaging==24.0 # via black, build, fixit, pyproject-api, pytest, sphi
|
||||||
pathspec==0.12.1 # via black, trailrunner
|
pathspec==0.12.1 # via black, trailrunner
|
||||||
pep8-naming==0.13.3 # via -r dev-requirements.in
|
pep8-naming==0.13.3 # via -r dev-requirements.in
|
||||||
pip-tools==7.4.1 # via -r dev-requirements.in
|
pip-tools==7.4.1 # via -r dev-requirements.in
|
||||||
platformdirs==4.2.0 # via black, tox, virtualenv
|
platformdirs==4.2.1 # via black, tox, virtualenv
|
||||||
pluggy==1.4.0 # via pytest, tox
|
pluggy==1.5.0 # via pytest, tox
|
||||||
pre-commit==3.7.0 # via -r dev-requirements.in
|
pre-commit==3.7.0 # via -r dev-requirements.in
|
||||||
pycodestyle==2.11.1 # via flake8
|
pycodestyle==2.11.1 # via flake8
|
||||||
pyflakes==3.2.0 # via autoflake, flake8
|
pyflakes==3.2.0 # via autoflake, flake8
|
||||||
|
@ -59,7 +59,7 @@ pyyaml==6.0.1 # via libcst, pre-commit
|
||||||
requests==2.31.0 # via sphinx
|
requests==2.31.0 # via sphinx
|
||||||
rich==12.6.0 # via gray
|
rich==12.6.0 # via gray
|
||||||
snowballstemmer==2.2.0 # via sphinx
|
snowballstemmer==2.2.0 # via sphinx
|
||||||
sphinx==7.2.6 # via -r dev-requirements.in
|
sphinx==7.3.7 # via -r dev-requirements.in
|
||||||
sphinxcontrib-applehelp==1.0.8 # via sphinx
|
sphinxcontrib-applehelp==1.0.8 # via sphinx
|
||||||
sphinxcontrib-devhelp==1.0.6 # via sphinx
|
sphinxcontrib-devhelp==1.0.6 # via sphinx
|
||||||
sphinxcontrib-htmlhelp==2.0.5 # via sphinx
|
sphinxcontrib-htmlhelp==2.0.5 # via sphinx
|
||||||
|
@ -68,14 +68,14 @@ sphinxcontrib-qthelp==1.0.7 # via sphinx
|
||||||
sphinxcontrib-serializinghtml==1.1.10 # via sphinx
|
sphinxcontrib-serializinghtml==1.1.10 # via sphinx
|
||||||
tokenize-rt==5.2.0 # via add-trailing-comma, pyupgrade
|
tokenize-rt==5.2.0 # via add-trailing-comma, pyupgrade
|
||||||
toml==0.10.2 # via autoflake
|
toml==0.10.2 # via autoflake
|
||||||
tomli==2.0.1 # via black, build, coverage, fixit, mypy, pip-tools, pyproject-api, pyproject-hooks, pytest, tox
|
tomli==2.0.1 # via black, build, coverage, fixit, mypy, pip-tools, pyproject-api, pyproject-hooks, pytest, sphinx, tox
|
||||||
tox==4.14.2 # via -r dev-requirements.in
|
tox==4.14.2 # via -r dev-requirements.in
|
||||||
trailrunner==1.4.0 # via fixit
|
trailrunner==1.4.0 # via fixit
|
||||||
typing-extensions==4.11.0 # via black, mypy
|
typing-extensions==4.11.0 # via black, mypy
|
||||||
unify==0.5 # via gray
|
unify==0.5 # via gray
|
||||||
untokenize==0.1.1 # via unify
|
untokenize==0.1.1 # via unify
|
||||||
urllib3==2.2.1 # via requests
|
urllib3==2.2.1 # via requests
|
||||||
virtualenv==20.25.1 # via pre-commit, tox
|
virtualenv==20.26.0 # via pre-commit, tox
|
||||||
wheel==0.43.0 # via pip-tools
|
wheel==0.43.0 # via pip-tools
|
||||||
|
|
||||||
# The following packages are considered to be unsafe in a requirements file:
|
# The following packages are considered to be unsafe in a requirements file:
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
aprslib>=0.7.0
|
aprslib>=0.7.0
|
||||||
click
|
click
|
||||||
click-params
|
click-params
|
||||||
click-completion
|
|
||||||
flask
|
flask
|
||||||
werkzeug
|
werkzeug
|
||||||
flask-httpauth
|
flask-httpauth
|
||||||
|
|
|
@ -34,7 +34,7 @@ h11==0.14.0 # via wsproto
|
||||||
idna==3.7 # via requests
|
idna==3.7 # via requests
|
||||||
imapclient==3.0.1 # via -r requirements.in
|
imapclient==3.0.1 # via -r requirements.in
|
||||||
importlib-metadata==7.1.0 # via ax253, kiss3
|
importlib-metadata==7.1.0 # via ax253, kiss3
|
||||||
itsdangerous==2.1.2 # via flask
|
itsdangerous==2.2.0 # via flask
|
||||||
jinja2==3.1.3 # via click-completion, flask
|
jinja2==3.1.3 # via click-completion, flask
|
||||||
kiss3==8.0.0 # via -r requirements.in
|
kiss3==8.0.0 # via -r requirements.in
|
||||||
loguru==0.7.2 # via -r requirements.in
|
loguru==0.7.2 # via -r requirements.in
|
||||||
|
@ -46,7 +46,7 @@ oslo-config==9.4.0 # via -r requirements.in
|
||||||
oslo-i18n==6.3.0 # via oslo-config
|
oslo-i18n==6.3.0 # via oslo-config
|
||||||
packaging==24.0 # via marshmallow
|
packaging==24.0 # via marshmallow
|
||||||
pbr==6.0.0 # via -r requirements.in, oslo-i18n, stevedore
|
pbr==6.0.0 # via -r requirements.in, oslo-i18n, stevedore
|
||||||
pluggy==1.4.0 # via -r requirements.in
|
pluggy==1.5.0 # via -r requirements.in
|
||||||
pygments==2.17.2 # via rich
|
pygments==2.17.2 # via rich
|
||||||
pyserial==3.5 # via pyserial-asyncio
|
pyserial==3.5 # via pyserial-asyncio
|
||||||
pyserial-asyncio==0.6 # via kiss3
|
pyserial-asyncio==0.6 # via kiss3
|
||||||
|
|
Loading…
Reference in New Issue