diff options
author | Aleš Mrázek <ales.mrazek@nic.cz> | 2024-08-06 11:07:53 +0200 |
---|---|---|
committer | Aleš Mrázek <ales.mrazek@nic.cz> | 2024-09-07 00:28:31 +0200 |
commit | 414e174505149a9e7731fa0fd7b3911158bff60f (patch) | |
tree | db1ce714e5f528dab91fce19c0c70395af4a4641 /utils/shell-completion | |
parent | Merge !1594: modules/workarounds: fix module initialization (diff) | |
download | knot-resolver-414e174505149a9e7731fa0fd7b3911158bff60f.tar.xz knot-resolver-414e174505149a9e7731fa0fd7b3911158bff60f.zip |
manager: moved everything out of the directory
Diffstat (limited to 'utils/shell-completion')
-rw-r--r-- | utils/shell-completion/client.bash | 33 | ||||
-rw-r--r-- | utils/shell-completion/client.fish | 6 | ||||
-rw-r--r-- | utils/shell-completion/meson.build | 13 |
3 files changed, 52 insertions, 0 deletions
diff --git a/utils/shell-completion/client.bash b/utils/shell-completion/client.bash new file mode 100644 index 00000000..b3c19419 --- /dev/null +++ b/utils/shell-completion/client.bash @@ -0,0 +1,33 @@ +#/usr/bin/env bash + +_kresctl_completion() +{ + COMPREPLY=() + local cur prev opts + + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + # check if there is a word is empty + # that means there is a space after last non-empty word + if [[ -z "$cur" ]] + then + # no word to complete, return all posible options + opts=$(kresctl completion --bash --space "${COMP_WORDS}") + else + opts=$(kresctl completion --bash "${COMP_WORDS}") + fi + + # if there is no completion from kresctl + # auto-complete just directories and files + if [[ -z "$opts" ]] + then + COMPREPLY=($(compgen -d -f "${cur}")) + else + COMPREPLY=( $(compgen -W "${opts}" ${cur}) ) + fi + + return 0 +} + +complete -o filenames -o dirnames -F _kresctl_completion kresctl diff --git a/utils/shell-completion/client.fish b/utils/shell-completion/client.fish new file mode 100644 index 00000000..ec3a0ab7 --- /dev/null +++ b/utils/shell-completion/client.fish @@ -0,0 +1,6 @@ +function __kresctl_completion + set -l args (commandline -pco) + eval command kresctl $args +end + +complete -c kresctl -a '(__kresctl_completion)' -f
\ No newline at end of file diff --git a/utils/shell-completion/meson.build b/utils/shell-completion/meson.build new file mode 100644 index 00000000..6c35ffe3 --- /dev/null +++ b/utils/shell-completion/meson.build @@ -0,0 +1,13 @@ +# CLI comletion for bash-shell +install_data( + sources: 'client.bash', + rename: 'kresctl', + install_dir: completion_dir / 'bash-completion' / 'completions' + ) + +# CLI completion for fish-shell +install_data( + sources: 'client.fish', + rename: 'kresctl.fish', + install_dir: completion_dir / 'fish' / 'completions' + ) |