1 # simple & stupid implementation of bash completion for pdnsutil
3 # (C) 2016 Joerg Jungermann
7 # put it into /etc/bash_completion.d/
9 # pdnsutil <TAB> - expands to known operations given as $1
10 # pdnsutil YOUNAMEIT <TAB> - completes to available zones, might be expensive with many (>10000) zones
15 _pdnsutil_helper_local_() {
18 local _PDNSUTIL_ALL_CMDS="activate-tsig-key activate-zone-key add-record add-zone-key backend-cmd b2b-migrate bench-db change-slave-zone-master check-zone check-all-zones clear-zone
19 create-bind-db create-slave-zone create-zone deactivate-tsig-key deactivate-zone-key delete-rrset delete-tsig-key delete-zone disable-dnssec
20 edit-zone export-zone-dnskey export-zone-key generate-tsig-key generate-zone-key get-meta hash-zone-record increase-serial import-tsig-key
21 import-zone-key load-zone list-algorithms list-keys list-zone list-all-zones list-tsig-keys rectify-zone rectify-all-zones remove-zone-key
22 replace-rrset secure-all-zones secure-zone set-kind set-nsec3 set-presigned set-publish-cdnskey set-publish-cds set-meta show-zone
23 unset-nsec3 unset-presigned unset-publish-cdnskey unset-publish-cds test-schema"
25 cur="${COMP_WORDS[COMP_CWORD]}"
26 prev="${COMP_WORDS[COMP_CWORD-1]}"
30 COMPREPLY=( $(compgen -W "$_PDNSUTIL_ALL_CMDS" -- $cur) )
34 case "$_PDNSUTIL_ALL_CMDS" in
35 "$prev "* | *" $prev "* | *" $prev" )
36 prevprev="${COMP_WORDS[COMP_CWORD-2]}"
37 COMPREPLY=( $(compgen -W "$($prevprev list-all-zones | head -n -1 )" -- $cur) )
43 complete -o default -F _pdnsutil_helper_local_ pdnsutil