completions: improved resolvectl completions and complete arguments

This commit is contained in:
exploide 2022-09-09 11:05:05 +02:00 committed by Fabian Boehm
parent 7de0b6410d
commit 15a89718ae

View file

@ -1,31 +1,71 @@
#resolvectl (systemd 248)
# resolvectl (systemd 250)
#variables
function __resolvectl_interfaces
resolvectl status | string replace -fr '^Link\s+\d+\s+\((.*)\)$' '$1'
end
function __resolvectl_protocols
resolvectl --protocol help | string match -rv ':$'
end
function __resolvectl_types
resolvectl --type help | string match -rv ':$'
end
function __resolvectl_classes
resolvectl --class help | string match -rv ':$'
end
function __resolvectl_commands
printf "%b\n" "query\tResolve domain names or IP addresses"\
"service\tResolve service records"\
"openpgp\tQuery PGP keys for email"\
"tlsa\tQuery TLS public keys"\
"status\tShow current DNS settings"\
"statistics\tShow resolver statistics"\
"reset-statistics\tReset statistics counters"\
"flush-caches\tFlush DNS RR caches"\
"reset-server-features\tFlushe all feature level information"\
"dns\tSet per-interface DNS servers"\
"domain\tSet per-interface search or routing domains"\
"default-route\tSet per-interface default route flag"\
"llmnr\tSet per-interface LLMNR settings"\
"mdns\tSet per-interface MulticastDNS settings"\
"dnssec\tSet per-interface DNSSEC settings"\
"dnsovertls\tSet per-interface DNS-over-TLS settings"\
"nta\tSet per-interface DNSSEC NTA domains"\
"revert\tRevert the per-interface DNS configuration"\
"log-level\tSet the log-level"
end
# variables
set -l seen __fish_seen_subcommand_from
set -l commands default-route dns dnsovertls dnssec domain flush-caches llmnr log-level mdns nta openpgp query reset-server-features reset-statistics revert service statistics status tlsa
set -l commands (__resolvectl_commands | string split -f 1 '\t')
#commands
complete -c resolvectl -x -n "not $seen $commands" -a "$commands"
# commands
complete -c resolvectl -f
complete -c resolvectl -n "not $seen $commands" -xa "(__resolvectl_commands)"
complete -c resolvectl -n "__fish_is_nth_token 2" -n "$seen status dns domain default-route llmnr mdns dnssec dnsovertls nta revert" -xa "(__resolvectl_interfaces)"
#options
complete -c resolvectl -f -n "not $seen $commands" -s 4 -d "Resolve IPv4 addresses"
complete -c resolvectl -f -n "not $seen $commands" -s 6 -d "Resolve IPv6 addresses"
complete -c resolvectl -x -n "not $seen $commands" -l cache -d "Allow response from cache"
complete -c resolvectl -x -n "not $seen $commands" -l class -s c -d "Query RR with DNS class"
complete -c resolvectl -x -n "not $seen $commands" -l cname -d "Follow CNAME redirects"
complete -c resolvectl -f -n "not $seen $commands" -l help -s h -d "Show this help"
complete -c resolvectl -x -n "not $seen $commands" -l interface -s i -d "Look on interface"
complete -c resolvectl -x -n "not $seen $commands" -l legend -d "Print headers and additional info"
complete -c resolvectl -x -n "not $seen $commands" -l network -d "Allow response from network"
complete -c resolvectl -f -n "not $seen $commands" -l no-pager -d "Do not pipe output into a pager"
complete -c resolvectl -x -n "not $seen $commands" -l protocol -s p -d "Look via protocol"
complete -c resolvectl -f -n "not $seen $commands" -l raw -d "Dump the answer as binary data"
complete -c resolvectl -x -n "not $seen $commands" -l search -d "Use search domains for single-label names"
complete -c resolvectl -x -n "not $seen $commands" -l service-address -d "Resolve address for services"
complete -c resolvectl -x -n "not $seen $commands" -l service-txt -d "Resolve TXT records for services"
complete -c resolvectl -x -n "not $seen $commands" -l synthesize -d "Allow synthetic response"
complete -c resolvectl -x -n "not $seen $commands" -l trust-anchor -d "Allow response from local trust anchor"
complete -c resolvectl -x -n "not $seen $commands" -l type -s t -d "Query RR with DNS type"
complete -c resolvectl -x -n "not $seen $commands" -l validate -d "Allow DNSSEC validation"
complete -c resolvectl -f -n "not $seen $commands" -l version -d "Show package version"
complete -c resolvectl -x -n "not $seen $commands" -l zone -d "Allow response from locally registered mDNS/LLMNR records"
# global options
complete -c resolvectl -s 4 -d "Resolve only IPv4"
complete -c resolvectl -s 6 -d "Resolve only IPv6"
complete -c resolvectl -l interface -s i -xa "(__resolvectl_interfaces)" -d "Interface to execute the query on"
complete -c resolvectl -l protocol -s p -xa "(__resolvectl_protocols)" -d "Network protocol for the query"
complete -c resolvectl -l type -s t -xa "(__resolvectl_types)" -d "DNS RR type for query"
complete -c resolvectl -l class -s c -xa "(__resolvectl_classes)" -d "DNS class for query"
complete -c resolvectl -l service-address -xa "true false" -d "Resolve address for SRV record"
complete -c resolvectl -l service-txt -xa "true false" -d "Resolve TXT records for services"
complete -c resolvectl -l cname -xa "true false" -d "Follow CNAME redirects"
complete -c resolvectl -l validate -xa "true false" -d "Allow DNSSEC validation"
complete -c resolvectl -l synthesize -xa "true false" -d "Allow synthetic response"
complete -c resolvectl -l cache -xa "true false" -d "Allow response from cache"
complete -c resolvectl -l zone -xa "true false" -d "Allow response from locally registered mDNS/LLMNR records"
complete -c resolvectl -l trust-anchor -xa "true false" -d "Use local trust anchors"
complete -c resolvectl -l network -xa "true false" -d "Allow response from network"
complete -c resolvectl -l search -xa "true false" -d "Use search domains for single-label names"
complete -c resolvectl -l raw -xa "payload packet" -d "Dump answer as binary data"
complete -c resolvectl -l legend -xa "true false" -d "Print headers and meta info"
complete -c resolvectl -l help -s h -d "Show help"
complete -c resolvectl -l version -d "Show version"
complete -c resolvectl -l no-pager -d "Do not pipe output into a pager"