diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/Makefile.am | 12 | ||||
-rw-r--r-- | samples/keymgr-completion.sh | 232 | ||||
-rw-r--r-- | samples/keymgr-completion.zsh | 116 |
3 files changed, 1 insertions, 359 deletions
diff --git a/samples/Makefile.am b/samples/Makefile.am index 4898cb0d5..c253c91ec 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -15,7 +15,7 @@ knot.sample.conf: knot.sample.conf.in $(edit) $${srcdir}$@.in >$@.tmp mv $@.tmp $@ -EXTRA_DIST = knot.sample.conf.in example.com.zone keymgr-completion.sh keymgr-completion.zsh +EXTRA_DIST = knot.sample.conf.in example.com.zone if HAVE_DAEMON @@ -24,19 +24,9 @@ install-data-local: knot.sample.conf $(INSTALL) -d $(DESTDIR)/$(config_dir); \ $(INSTALL_DATA) knot.sample.conf $(srcdir)/example.com.zone $(DESTDIR)/$(config_dir); \ fi -if HAVE_BASH_COMPLETIONS - if [ \! -f $(DESTDIR)/$(bash_completions_dir)/keymgr ]; then \ - $(INSTALL) -d $(DESTDIR)/$(bash_completions_dir); \ - $(INSTALL_DATA) $(srcdir)/keymgr-completion.sh $(DESTDIR)/$(bash_completions_dir)/keymgr; \ - fi -endif # HAVE_BASH_COMPLETIONS - uninstall-local: -rm -rf $(DESTDIR)/$(config_dir)/knot.sample.conf \ $(DESTDIR)/$(config_dir)/example.com.zone -if HAVE_BASH_COMPLETIONS - -rm -rf $(DESTDIR)/$(bash_completions_dir)/keymgr -endif # HAVE_BASH_COMPLETIONS endif # HAVE_DAEMON diff --git a/samples/keymgr-completion.sh b/samples/keymgr-completion.sh deleted file mode 100644 index eec46ecf9..000000000 --- a/samples/keymgr-completion.sh +++ /dev/null @@ -1,232 +0,0 @@ -# keymgr(1) completion -*- shell-script -*- - -_keymgr() -{ - local cur prev words cword - _init_completion || return - - - case $prev in - -V|-version) - return 0 - ;; - -h|--help) - return 0 - ;; - -d|--dir) - _filedir -d - return 0; - ;; - esac - - local count start cmd sub1cmd sub2cmd sub3cmd - if [[ ${words[1]} == -* ]]; then - start=3 - else - start=1 - fi - cmd=${words[start]} - sub1cmd=${words[$((start + 1))]} - sub2cmd=${words[$((start + 2))]} - sub3cmd=${words[$((start + 3))]} - - if [[ -z $cmd ]]; then - case $cur in - -*) - local c="--version --help --dir" - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - return 0 - ;; - esac - fi - - count=1 #counts how many levels are we deep; required for user-input strings - case $cmd in - init) - ;; - keystore) - case $sub1cmd in - list) - ;; - *) - COMPREPLY=( $( compgen -W 'list' -- "$cur" ) ) - ;; - esac - ;; - policy) - count=$((count + 1)) - case $sub1cmd in - add) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - COMPREPLY=( $( compgen -W 'algorithm dnskey-ttl - ksk-size zsk-size zsk-lifetime rrsig-lifetime - rrsig-refresh nsec3 soa-min-ttl zone-max-ttl delay' \ - -- "$cur" ) ) - fi - ;; - list|remove|show) - count=$((count + 1)) - if [[ $count -eq $cword ]]; then - local c=$( keymgr policy list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - set) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - COMPREPLY=( $( compgen -W 'algorithm dnskey-ttl - ksk-size zsk-size zsk-lifetime rrsig-lifetime - rrsig-refresh nsec3 soa-min-ttl zone-max-ttl delay' \ - -- "$cur" ) ) - else - local c=$( keymgr policy list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - *) - COMPREPLY=( $( compgen -W 'add list remove set show' \ - -- "$cur" ) ) - ;; - esac - ;; - zone) - count=$((count + 1)) - case $sub1cmd in - add) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - count=$((count + 1)) - case $sub3cmd in - policy) - count=$((count + 1)) - if [[ $count -eq $cword ]]; then - local c=$( keymgr policy list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - *) - COMPREPLY=( $( compgen -W 'policy' -- "$cur" ) ) - ;; - esac - fi - ;; - key) - count=$((count + 1)) - case $sub2cmd in - generate) - count=$((count + 1)) - if [[ $count -eq $cword ]]; then - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - else - COMPREPLY=( $( compgen -W 'algorithm size - ksk publish active retire remove' -- "$cur" ) ) - fi - ;; - import) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - _filedir - else - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - list) - count=$((count + 1)) - if [[ $count -eq $cword ]]; then - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - set) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - COMPREPLY=( $( compgen -W ' publish - active retire remove' -- "$cur" ) ) - else - local c=$( keymgr zone key list "$sub3cmd" 2>/dev/null | cut -f 2 -d ' ' ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - else - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - show|ds) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - local c=$( keymgr zone key list "$sub3cmd" 2>/dev/null | cut -f 2 -d ' ' ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - else - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - *) - COMPREPLY=( $( compgen -W 'generate import - list set show ds' -- "$cur" ) ) - ;; - esac - ;; - list) - ;; - remove) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - case $sub3cmd in - force) - ;; - *) - COMPREPLY=( $( compgen -W 'force' -- "$cur" ) ) - ;; - esac - else - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - show) - count=$((count + 1)) - if [[ $count -eq $cword ]]; then - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - set) - count=$((count + 1)) - if [[ $count -ne $cword ]]; then - count=$((count + 1)) - case $sub3cmd in - policy) - count=$((count + 1)) - if [[ $count -eq $cword ]]; then - local c=$( keymgr policy list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - *) - COMPREPLY=( $( compgen -W 'policy' -- "$cur" ) ) - ;; - esac - else - local c=$( keymgr zone list 2>/dev/null ) - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - fi - ;; - *) - COMPREPLY=( $( compgen -W 'add key list remove set show' \ - -- "$cur" ) ) - ;; - esac - ;; - *) - local c="init zone policy keystore" - COMPREPLY=( $( compgen -W "$c" -- "$cur" ) ) - ;; - esac -} -complete -F _keymgr keymgr diff --git a/samples/keymgr-completion.zsh b/samples/keymgr-completion.zsh deleted file mode 100644 index babca0bec..000000000 --- a/samples/keymgr-completion.zsh +++ /dev/null @@ -1,116 +0,0 @@ -#compdef keymgr - - -local -a matchany policy_list policies zone_list zones files -matchany=(/$'[^\0]##\0'/) -key_list=( \( $(keymgr keystore list 2>/dev/null) \) ) -keys=( \( $matchany ":keys:keys:$key_list" \) ) -policy_list=( \( $(keymgr policy list 2>/dev/null) \) ) -policies=( \( $matchany ":policies:policies:$policy_list" \) ) -zone_list=( \( $(keymgr zone list 2>/dev/null) \) ) -zones=( \( $matchany ":zones:zones:$zone_list" \) ) -files=(/$'[^\0]##\0'/ ':file:file name:_files') - -local -a keystore_cmds -_regex_words keystore-commands "keystore commands" \ - 'l*ist:list all keys' -keystore_cmds=("$reply[@]") - -local -a policy_subcmds policy_add_cmds policy_set_cmds -_regex_words policy-add-commands "policy add commands" \ - 'a*lgorithm' \ - 'de*lay' \ - 'dn*skey-ttl' \ - 'k*sk-size' \ - 'n*sec3' \ - 'rrsig-l*ifetime' \ - 'rrsig-r*efresh' \ - 's*oa-min-ttl' \ - 'zo*ne-max-ttl' \ - 'zsk-l*ifetime' \ - 'zsk-s*ize' -policy_subcmds=("$reply[@]") -policy_add_cmds=( $matchany $policy_subcmds ) -policy_set_cmds=( $policies $policy_subcmds ) - -local -a policy_cmds -_regex_words policy-commands "policy commands" \ - 'a*dd:add a policy:$policy_add_cmds' \ - 'l*ist:list all added policies' \ - 'r*emove:remove a policy:$policies' \ - 'se*t:set policy attributes:$policy_set_cmds' \ - 'sh*ow:show policy attributes:$policies' -policy_cmds=("$reply[@]") - -local -a zone_add_cmds -_regex_words zone-add-commands "zone add commands" \ - 'p*olicy:set zone policy:$policies' -zone_add_cmds=( $matchany "$reply[@]") - -local -a zone_key_generate_cmds -_regex_words zone-key-generate-commands "zone key generate commands" \ - 'ac*tive' \ - 'al*gorithm' \ - 'k*sk' \ - 'p*ublish' \ - 'rem*ove' \ - 'ret*ire' \ - 's*ize' -zone_key_generate_cmds=( $matchany "$reply[@]") - -local -a zone_key_import_cmds -zone_key_import_cmds=( $zones $files ) - -local -a zone_key_set_cmds -_regex_words zone-key-set-commands "zone key set commands" \ - 'a*ctive' \ - 'p*ublish' \ - 'rem*ove' \ - 'ret*ire' -zone_key_set_cmds=( $zones "$reply[@]") - -local -a zone_key_cmds -_regex_words zone-key-commands "zone key commands" \ - 'g*enerate:generate a key:$zone_key_generate_cmds' \ - 'i*mport:import keys from file:$zone_key_import_cmds' \ - 'l*ist:list keys:$zones' \ - 'sh*ow:show a key:$zones' \ - 'd*s:show DS records for a key:$zones' \ - 'se*t:set attributes of a key:$zone_key_set_cmds' -zone_key_cmds=("$reply[@]") - -local -a zone_remove_cmds -_regex_words zone-remove-commands "zone remove commands" \ - 'f*orce:force remove' -zone_remove_cmds=( $zones "$reply[@]") - -local -a zone_set_cmds -_regex_words zone-set-commands "zone set commands" \ - 'p*olicy:set zone policy:$policies' -zone_set_cmds=( $zones "$reply[@]") - -local -a zone_cmds -_regex_words zone-commands "zone commands" \ - 'a*dd:add a zone:$zone_add_cmds' \ - 'k*ey:manipulate zone keys:$zone_key_cmds' \ - 'l*ist:list all added zones' \ - 'r*emove:remove a zone:$zones' \ - 'se*t:set zone attributes:$zone_set_cmds' \ - 'sh*ow:show zone attributes:$zones' -zone_cmds=("$reply[@]") - -# Arguments to _regex_arguments, built up in array $args. -local -a args reply -# Command word. Don't care what that is. -args=( $matchany ) - -_regex_words commands "keymgr command" \ - 'i*nit:initialize KASP directory and default keystore' \ - 'k*eystore:manipulate keystore:$keystore_cmds' \ - 'p*olicy:manipulate policies:$policy_cmds' \ - 'z*one:manipule zones:$zone_cmds' -args+=("$reply[@]") - -_regex_arguments _keymgr "${args[@]}" - -_keymgr "$@" |