about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2018-03-30 16:12:35 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-03-30 16:12:35 +0200
commit20a92b857e7adf9be1a6afd3249b34c0da0e5c1b (patch)
treeb5adab8845318c2860b799c87894f9e4fac20152
parentbdf09270be2c5fb8a61b9e7f6bd0d0c194342000 (diff)
downloadzsh-20a92b857e7adf9be1a6afd3249b34c0da0e5c1b.tar.gz
zsh-20a92b857e7adf9be1a6afd3249b34c0da0e5c1b.tar.xz
zsh-20a92b857e7adf9be1a6afd3249b34c0da0e5c1b.zip
42570: new completion for drill and factor out DNS type completion
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Unix/Command/_dig11
-rw-r--r--Completion/Unix/Command/_drill46
-rw-r--r--Completion/Unix/Type/_dns_types8
4 files changed, 59 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 5812c75b7..8d6c43b47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2018-03-30  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
+	* 42570: Completion/Unix/Command/_drill,
+	Completion/Unix/Command/_dig, Completion/Unix/Type/_dns_types:
+	new completion for drill and factor out DNS type completion
+
 	* 42560: Src/utils.c: silence sign-compare compiler warnings
 
 	* 42566: Completion/Unix/Command/_strings: new strings completion
diff --git a/Completion/Unix/Command/_dig b/Completion/Unix/Command/_dig
index a4e175808..5feb71fef 100644
--- a/Completion/Unix/Command/_dig
+++ b/Completion/Unix/Command/_dig
@@ -1,14 +1,5 @@
 #compdef dig
 
-_dns_types() {
-  local expl
-  _description dns-types expl 'DNS type'
-  compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z}' \
-      ANY A AAAA AFSDB APL AXFR CAA CDNSKEY CDS CERT CNAME DHCID DLV DNAME \
-      DNSKEY DS HIP HINFO IPSECKEY IXFR KEY KX LOC MX NAPTR NS NSEC NSEC3 \
-      NSEC3PARAM OPT PTR RRSIG RP SIG SOA SPF SRV SSHFP TA TKEY TLSA TSIG TXT
-}
-
 local curcontext="$curcontext" state line expl
 local -a alts args
 [[ -prefix + ]] && args=(
@@ -66,7 +57,7 @@ local -a alts args
   '*+'{no,}'besteffort[try to parse even malformed messages]'
   '*+'{no,}'dnssec[request DNSSEC records]'
   '*+'{no,}'sigchase[chase DNSSEC signature chains]'
-  '*+trusted-key=[specify file conrtaing trusted kets]:file:_files'
+  '*+trusted-key=[specify file containing trusted keys]:file:_files'
   '*+'{no,}'topdown[do DNSSEC validation in top down mode]'
   '*+'{no,}'nsid[include EDNS name server ID request in query]'
   '*+'{no,}'ttlid[display the TTL whening printing the record]'
diff --git a/Completion/Unix/Command/_drill b/Completion/Unix/Command/_drill
new file mode 100644
index 000000000..68fa7917b
--- /dev/null
+++ b/Completion/Unix/Command/_drill
@@ -0,0 +1,46 @@
+#compdef drill
+
+local curcontext="$curcontext" ret=1
+local -a state line expl
+
+_arguments -s -S -C \
+  '-D[enable DNSSEC (DO bit)]' \
+  '-T[trace from the root down]' \
+  '-S[chase signature(s) to a known key]' \
+  '-I[specify source address to query from]:source address' \
+  '(-Q)-V+[specify verbosity]:number (0-5)' \
+  '(-V)-Q[quiet mode (overrules -V)]' \
+  '-f+[read packet from file and send it]:file:_files' \
+  '-i+[read packet from file and print it]:file:_files' \
+  '-w+[write answer packet to file]:file:_files' \
+  '-q+[write query packet to file]:file:_files' \
+  '(- *)-h[display usage information]' \
+  '(- *)-v[display version information]' \
+  '(-6)-4[stay on ipv4]' \
+  '(-4)-6[stay on ipv6]' \
+  '-a[fallback to EDNS0 and TCP if the answer is truncated]' \
+  '-b+[specify buffer size (defaults to 512 b)]:size (bytes) [512]' \
+  '-c+[use specified file for rescursive nameserver configuration]:file [/etc/resolv.conf]:_files' \
+  '-k+[specify a file that contains a trusted DNSSEC key]:file:_files' \
+  '*-o+[set/unset header bits]:mnemonic (uppercase sets, lower unsets):_sequence compadd - QR qr AA aa TC tc RD rd CD cd RA ra AD ad' \
+  '-p+[use specified remote port number]:port:_ports' \
+  '-s[show the DS RR for each key in a packet]' \
+  '-x[do a reverse lookup]' \
+  '-r+[use specified file as root servers hint file]:file:_files' \
+  '-t[send the query with tcp]' '!(-t)-u' \
+  '-d+[use specified domain as the start point for the trace]:domain' \
+  '-y+[specify named base64 tsig key, and optional algorithm]:name\:key\:algorithm [hmac-md5.sig-alg.reg.int]' \
+  "-z[don't randomize the nameservers before use]" \
+  '*:args:->args' && ret=0
+
+if [[ -n $state ]]; then
+  if compset -P @; then
+    _wanted hosts expl 'DNS server' _hosts && ret=0;
+  else
+    _alternative 'hosts:host:_hosts' \
+       'types:query type:_dns_types' \
+       'classes:query class:compadd -M "m:{a-z}={A-Z}" - IN CS CH HS' && ret=0
+  fi
+fi
+
+return ret
diff --git a/Completion/Unix/Type/_dns_types b/Completion/Unix/Type/_dns_types
new file mode 100644
index 000000000..b6bc2e680
--- /dev/null
+++ b/Completion/Unix/Type/_dns_types
@@ -0,0 +1,8 @@
+#autoload
+
+local expl
+_description dns-types expl 'DNS type'
+compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z}' \
+    ANY A AAAA AFSDB APL AXFR CAA CDNSKEY CDS CERT CNAME DHCID DLV DNAME \
+    DNSKEY DS HIP HINFO IPSECKEY IXFR KEY KX LOC MX NAPTR NS NSEC NSEC3 \
+    NSEC3PARAM OPT PTR RRSIG RP SIG SOA SPF SRV SSHFP TA TKEY TLSA TSIG TXT