diff options
Diffstat (limited to 'completions/nslookup')
-rw-r--r-- | completions/nslookup | 77 |
1 files changed, 48 insertions, 29 deletions
diff --git a/completions/nslookup b/completions/nslookup index 3341b1f..b04b03a 100644 --- a/completions/nslookup +++ b/completions/nslookup @@ -1,32 +1,42 @@ # bash completion for nslookup -*- shell-script -*- -_bind_queryclass() +_comp_cmd_nslookup__queryclass() { - COMPREPLY+=($(compgen -W 'IN CH HS ANY' -- "$cur")) + _comp_compgen -a -- -W 'IN CH HS ANY' } -_bind_querytype() +_comp_cmd_nslookup__querytype() { # https://en.wikipedia.org/wiki/List_of_DNS_record_types - COMPREPLY+=($(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME - DNSKEY DS HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC NSEC3 NSEC3PARAM PTR - RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur")) + # Resource records + local -a types=( + A AAAA AFSDB APL CAA CDNSKEY CDS CERT CNAME CSYNC DHCID DLV DNAME + DNSKEY DS EUI48 EUI64 HINFO HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC + NSEC3 NSEC3PARAM OPENPGPKEY PTR RRSIG RP SIG SMIMEA SOA SRV SSHFP TA + TKEY TLSA TSIG TXT URI ZONEMD SVCB HTTPS + ) + # Other types/pseudo record types + types+=(AXFR IXFR OPT) + # Selected obsolete record types + types+=(SPF) + + _comp_compgen -a -- -W '"${types[@]}"' } -_nslookup() +_comp_cmd_nslookup() { - local cur prev words cword - _init_completion -n = || return + local cur prev words cword comp_args + _comp_initialize -n = -- "$@" || return case $cur in -class=* | -cl=*) cur=${cur#*=} - _bind_queryclass + _comp_cmd_nslookup__queryclass return ;; -querytype=* | -type=* | -q=* | -ty=*) cur=${cur#*=} - _bind_querytype + _comp_cmd_nslookup__querytype return ;; -?*=*) @@ -35,38 +45,38 @@ _nslookup() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '-all -class= -debug -nodebug -d2 -nod2 - -domain= -search -nosearch -port= -querytype= -recurse -norecurse - -retry= -timeout= -vc -novc -fail -nofail' -- "$cur")) + _comp_compgen -- -W '-all -class= -debug -nodebug -d2 -nod2 -domain= + -search -nosearch -port= -querytype= -recurse -norecurse -retry= + -timeout= -vc -novc -fail -nofail' [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - local args - _count_args = - if ((args <= 2)); then - _known_hosts_real -- "$cur" - [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-) + local REPLY + _comp_count_args + if ((REPLY <= 2)); then + _comp_compgen_known_hosts -- "$cur" + [[ $REPLY -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-) fi } && - complete -F _nslookup nslookup + complete -F _comp_cmd_nslookup nslookup -_host() +_comp_cmd_host() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in -c) - _bind_queryclass + _comp_cmd_nslookup__queryclass return ;; -t) - _bind_querytype + _comp_cmd_nslookup__querytype return ;; -m) - COMPREPLY=($(compgen -W 'trace record usage' -- "$cur")) + _comp_compgen -- -W 'trace record usage' return ;; -N | -R | -W) @@ -75,12 +85,21 @@ _host() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi - _known_hosts_real -- "$cur" + local REPLY + _comp_count_args -a "-*[ctmNRW]" + if ((REPLY == 1)); then + _comp_compgen_known_hosts -- "$cur" + elif ((REPLY == 2)); then + local ipvx + [[ ${words[*]} =~ \ -[^\ ]*([46]) ]] && ipvx=-${BASH_REMATCH[1]} + # shellcheck disable=SC2086 + _comp_compgen_known_hosts ${ipvx-} -- "$cur" + fi } && - complete -F _host host + complete -F _comp_cmd_host host # ex: filetype=sh |