1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #13273 from RPigott/zshcomp

Enable resolvectl zsh completions
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-08-14 18:21:12 +02:00 committed by GitHub
commit 15e19aa1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 18 deletions

View File

@ -1,4 +1,4 @@
#compdef systemd-resolve -*- shell-script -*- #compdef resolvectl systemd-resolve -*- shell-script -*-
# SPDX-License-Identifier: LGPL-2.1+ # SPDX-License-Identifier: LGPL-2.1+
# #
# This file is part of systemd. # This file is part of systemd.
@ -16,33 +16,54 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>. # along with systemd; If not, see <http://www.gnu.org/licenses/>.
(( $+functions[_systemd-resolve_protocols] )) || (( $+functions[_resolvectl_protocols] )) ||
_systemd-resolve_protocols() { _resolvectl_protocols() {
local -a _protocol local -a _protocol
_protocol=( $(_call_program protocol ${service} --legend=no --protocol help; echo help) ) _protocol=( $(_call_program protocol ${service} --legend=no --protocol help; echo help) )
_values 'protocol' "$_protocol[@]" _values 'protocol' "$_protocol[@]"
} }
(( $+functions[_systemd-resolve_types] )) || (( $+functions[_resolvectl_types] )) ||
_systemd-resolve_types() { _resolvectl_types() {
local -a _type local -a _type
_type=( $(_call_program type ${service} --legend=no --type help; echo help) ) _type=( $(_call_program type ${service} --legend=no --type help; echo help) )
_values 'type' "$_type[@]" _values 'type' "$_type[@]"
} }
(( $+functions[_systemd-resolve_classes] )) || (( $+functions[_resolvectl_classes] )) ||
_systemd-resolve_classes() { _resolvectl_classes() {
local -a _class local -a _class
_class=( $(_call_program class ${service} --legend=no --class help; echo help) ) _class=( $(_call_program class ${service} --legend=no --class help; echo help) )
_values 'class' "$_class[@]" _values 'class' "$_class[@]"
} }
(( $+functions[_systemd-resolve_none] )) || (( $+functions[_resolvectl_commands] )) ||
_systemd-resolve_none() { _resolvectl_commands() {
_alternative : \ local -a _resolvectl_cmds
'domain:DNS address:' \ _resolvectl_cmds=(
'address:email address:' default-route:"Configure per-interface default-route setting"
} dns:"Configure per-interface DNS configuration"
dnsovertls:"Configure per-interface dnsovertls enabled status"
dnssec:"Configure per-interface dnssec enabled status"
domain:"Configure per-interface search and route-only domains"
flush-caches:"Flushes all DNS resource record caches the service maintains locally"
llmnr:"Configure per-interface llmnr enabled status"
mdns:"Configure per-interface mdns enabled status"
nta:"Configure per-interface nta domains"
openpgp:"Retrieve openpgp keys for an email"
query:"Resolve domain names, IPv4 and IPv6 addresses"
reset-server-features:"Flushes all feature level information the resolver has learned about specific servers"
reset-statistics:"Resets the statistics counter show in statistics to zero"
revert:"Revert the per-interfce DNS configuration"
service:"Resolve DNS-SD and SRV services"
status:"Show the global and per-link DNS settings currently in effect"
tlsa:"Query tlsa public keys stored as TLSA resource records"
)
if (( CURRENT == 1 )); then
_describe -t commands 'resolvectl commands' _resolvectl_cmds
fi
}
_arguments \ _arguments \
{-h,--help}'[Print a short help text and exit]' \ {-h,--help}'[Print a short help text and exit]' \
@ -51,9 +72,9 @@ _arguments \
'-4[Resolve IPv4 addresses]' \ '-4[Resolve IPv4 addresses]' \
'-6[Resolve IPv6 addresses]' \ '-6[Resolve IPv6 addresses]' \
{-i+,--interface=}'[Look on interface]:interface:_net_interfaces' \ {-i+,--interface=}'[Look on interface]:interface:_net_interfaces' \
{-p+,--protocol=}'[Look via protocol]:protocol:_systemd-resolve_protocols' \ {-p+,--protocol=}'[Look via protocol]:protocol:_resolvectl_protocols' \
{-t+,--type=}'[Query RR with DNS type]:type:_systemd-resolve_types' \ {-t+,--type=}'[Query RR with DNS type]:type:_resolvectl_types' \
{-c+,--class=}'[Query RR with DNS class]:class:_systemd-resolve_classes' \ {-c+,--class=}'[Query RR with DNS class]:class:_resolvectl_classes' \
'--service[Resolve services]' \ '--service[Resolve services]' \
'--service-address=no[Do not resolve address for services]' \ '--service-address=no[Do not resolve address for services]' \
'--service-txt=no[Do not resolve TXT records for services]' \ '--service-txt=no[Do not resolve TXT records for services]' \
@ -63,4 +84,4 @@ _arguments \
'--search=no[Do not use search domains]' \ '--search=no[Do not use search domains]' \
'--statistics[Show resolver statistics]' \ '--statistics[Show resolver statistics]' \
'--reset-statistics[Reset resolver statistics]' \ '--reset-statistics[Reset resolver statistics]' \
'*::default: _systemd-resolve_none' '*::default: _resolvectl_commands'

View File

@ -33,7 +33,7 @@ if zshcompletiondir != 'no'
['_machinectl', 'ENABLE_MACHINED'], ['_machinectl', 'ENABLE_MACHINED'],
['_networkctl', 'ENABLE_NETWORKD'], ['_networkctl', 'ENABLE_NETWORKD'],
['_systemd-inhibit', 'ENABLE_LOGIND'], ['_systemd-inhibit', 'ENABLE_LOGIND'],
['_systemd-resolve', 'ENABLE_RESOLVE'], ['_resolvectl', 'ENABLE_RESOLVE'],
['_systemd-tmpfiles', 'ENABLE_TMPFILES'], ['_systemd-tmpfiles', 'ENABLE_TMPFILES'],
['_timedatectl', 'ENABLE_TIMEDATED'], ['_timedatectl', 'ENABLE_TIMEDATED'],
] ]