1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Add Shell Completion script generation

`dnsutils shell-completion <shell>` will generate a shell completion
script for the specified shell (bash or zsh). If no shell is specified,
the script will be generated for the current shell, using `$SHELL`.
This commit is contained in:
Tom Whitwell
2023-06-20 16:45:16 +01:00
parent cb3c020f45
commit b91bcf373f
7 changed files with 413 additions and 1 deletions

View File

@ -0,0 +1,20 @@
#compdef "{{.App.Name}}"
_dnscontrol() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
else
_files
fi
}
compdef "_dnscontrol" "{{.App.Name}}"