mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
Add bash completion support for nvtake
This commit is contained in:
parent
ade7d53a1a
commit
465b9ee4dd
3 changed files with 27 additions and 0 deletions
|
@ -85,3 +85,13 @@ def cmp() -> None:
|
|||
oldver = oldvers.get(name, None)
|
||||
if oldver != newver:
|
||||
print('%s %s -> %s' % (name, oldver, newver))
|
||||
|
||||
def completion() -> None:
|
||||
parser = argparse.ArgumentParser(description='helper script to generate completion for nvchecker')
|
||||
core.add_common_arguments(parser)
|
||||
args = parser.parse_args()
|
||||
if core.process_common_arguments(args):
|
||||
return
|
||||
|
||||
entries = core.load_file(args.file, use_keymanager=False)[0]
|
||||
print(" ".join(entries))
|
||||
|
|
16
scripts/nvtake.bash_completion
Normal file
16
scripts/nvtake.bash_completion
Normal file
|
@ -0,0 +1,16 @@
|
|||
# MIT licensed
|
||||
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.
|
||||
|
||||
_nvtake() {
|
||||
local cur _nvchecker_conf_mtime
|
||||
_init_completion || return
|
||||
|
||||
_nvchecker_conf_mtime=$(stat -c %Y $HOME/.config/nvchecker/nvchecker.toml)
|
||||
if [ -z "$_nvtake_completion_cache" -o "$_nvchecker_conf_mtime" != "$_nvchecker_conf_mtime_cached" ]; then
|
||||
_nvtake_completion_cache="$(nvcompletion)"
|
||||
_nvchecker_conf_mtime_cached=$_nvchecker_conf_mtime
|
||||
fi
|
||||
|
||||
COMPREPLY=( $(compgen -W "$_nvtake_completion_cache" -- "$cur") )
|
||||
} &&
|
||||
complete -F _nvtake nvtake
|
1
setup.py
1
setup.py
|
@ -36,6 +36,7 @@ setup(
|
|||
'nvchecker = nvchecker.__main__:main',
|
||||
'nvtake = nvchecker.tools:take',
|
||||
'nvcmp = nvchecker.tools:cmp',
|
||||
'nvcompletion = nvchecker.tools:completion',
|
||||
],
|
||||
},
|
||||
scripts=['scripts/nvchecker-ini2toml'],
|
||||
|
|
Loading…
Add table
Reference in a new issue