mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
Merge pull request #32613 from arthurzam/bash-v256
More shell-completions work
This commit is contained in:
commit
dafcba5940
|
@ -24,7 +24,7 @@ __contains_word () {
|
|||
done
|
||||
}
|
||||
|
||||
__get_interfaces(){
|
||||
__get_interfaces() {
|
||||
local name
|
||||
for name in $(cd /sys/class/net && command ls); do
|
||||
[[ "$name" != "lo" ]] && echo "$name"
|
||||
|
@ -36,10 +36,10 @@ _resolvectl() {
|
|||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-h --help --version -4 -6 --legend=no --cname=no
|
||||
--validate=no --synthesize=no --cache=no --zone=no
|
||||
--validate=no --synthesize=no --cache=no --relax-single-label=no --zone=no
|
||||
--trust-anchor=no --network=no --service-address=no
|
||||
--service-txt=no --search=no --stale-data=no --no-pager'
|
||||
[ARG]='-t --type -c --class -i --interface -p --protocol --raw'
|
||||
[ARG]='-t --type -c --class -i --interface -p --protocol --raw --json'
|
||||
)
|
||||
local -A VERBS=(
|
||||
[DOMAIN]='query service openpgp'
|
||||
|
@ -50,7 +50,7 @@ _resolvectl() {
|
|||
[RESOLVE]='llmnr mdns'
|
||||
[DNSSEC]='dnssec'
|
||||
[DNSOVERTLS]='dnsovertls'
|
||||
[STANDALONE]='statistics reset-statistics flush-caches reset-server-features show-cache'
|
||||
[STANDALONE]='statistics reset-statistics flush-caches reset-server-features monitor show-cache show-server-state'
|
||||
[LOG_LEVEL]='log-level'
|
||||
)
|
||||
local -A ARGS=(
|
||||
|
@ -60,14 +60,13 @@ _resolvectl() {
|
|||
[DNSSEC]='yes no allow-downgrade'
|
||||
[DNSOVERTLS]='yes no opportunistic'
|
||||
)
|
||||
local interfaces=$( __get_interfaces )
|
||||
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--interface|-i)
|
||||
comps="$interfaces"
|
||||
comps=$( __get_interfaces )
|
||||
;;
|
||||
--protocol|-p|--type|-t|--class|-c)
|
||||
--protocol|-p|--type|-t|--class|-c|--json)
|
||||
comps=$( resolvectl --legend=no "$prev" help; echo help )
|
||||
;;
|
||||
--raw)
|
||||
|
@ -98,7 +97,7 @@ _resolvectl() {
|
|||
comps=''
|
||||
|
||||
elif __contains_word "$verb" ${VERBS[STATUS]}; then
|
||||
comps="$interfaces"
|
||||
comps=$( __get_interfaces )
|
||||
|
||||
elif __contains_word "$verb" ${VERBS[LOG_LEVEL]}; then
|
||||
comps='debug info notice warning err crit alert emerg'
|
||||
|
@ -118,6 +117,7 @@ _resolvectl() {
|
|||
fi
|
||||
|
||||
elif __contains_word "$verb" ${VERBS[LINK]} ${VERBS[BOOLEAN]} ${VERBS[RESOLVE]} ${VERBS[DNSSEC]} ${VERBS[DNSOVERTLS]}; then
|
||||
local interfaces=$( __get_interfaces )
|
||||
for ((i++; i < COMP_CWORD; i++)); do
|
||||
if __contains_word "${COMP_WORDS[i]}" $interfaces &&
|
||||
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
|
||||
|
|
|
@ -67,7 +67,7 @@ _systemd_analyze() {
|
|||
)
|
||||
|
||||
local -A VERBS=(
|
||||
[STANDALONE]='time blame unit-paths exit-status calendar timestamp timespan'
|
||||
[STANDALONE]='time blame unit-files unit-paths exit-status capability compare-versions calendar timestamp timespan pcrs srk'
|
||||
[CRITICAL_CHAIN]='critical-chain'
|
||||
[DOT]='dot'
|
||||
[DUMP]='dump'
|
||||
|
@ -79,11 +79,12 @@ _systemd_analyze() {
|
|||
[INSPECT_ELF]='inspect-elf'
|
||||
[PLOT]='plot'
|
||||
[ARCHITECTURES]='architectures'
|
||||
[FDSTORE]='fdstore'
|
||||
)
|
||||
|
||||
local CONFIGS='systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf
|
||||
local CONFIGS='locale.conf systemd/bootchart.conf systemd/coredump.conf systemd/journald.conf
|
||||
systemd/journal-remote.conf systemd/journal-upload.conf systemd/logind.conf
|
||||
systemd/resolved.conf systemd/networkd.conf systemd/resolved.conf
|
||||
systemd/resolved.conf systemd/networkd.conf systemd/pstore.conf systemd/resolved.conf
|
||||
systemd/sleep.conf systemd/system.conf systemd/timedated.conf
|
||||
systemd/timesyncd.conf systemd/user.conf udev/udev.conf'
|
||||
|
||||
|
@ -211,6 +212,13 @@ _systemd_analyze() {
|
|||
else
|
||||
comps=$( __get_architectures )
|
||||
fi
|
||||
|
||||
elif __contains_word "$verb" ${VERBS[FDSTORE]}; then
|
||||
if [[ $cur = -* ]]; then
|
||||
comps='--help --version --system --user --global -H --host -M --machine --no-pager --json=off --json=pretty --json=short --root --image'
|
||||
else
|
||||
comps=$( __get_services $mode )
|
||||
fi
|
||||
fi
|
||||
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
|
|
70
shell-completion/bash/systemd-vmspawn
Normal file
70
shell-completion/bash/systemd-vmspawn
Normal file
|
@ -0,0 +1,70 @@
|
|||
# shellcheck shell=bash
|
||||
# systemd-vmspawn(1) completion -*- shell-script -*-
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
#
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# systemd is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with systemd; If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
__contains_word() {
|
||||
local w word=$1; shift
|
||||
for w in "$@"; do
|
||||
[[ $w = "$word" ]] && return
|
||||
done
|
||||
}
|
||||
|
||||
_systemd_vmspawn() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} words cword
|
||||
local i verb comps
|
||||
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-h --help --version -q --quiet --no-pager -n --network-tap --network-user-mode'
|
||||
[PATH]='-D --directory -i --image --linux --initrd --extra-drive --forward-journal'
|
||||
[BOOL]='--kvm --vsock --tpm --secure-boot --discard-disk --register --pass-ssh-key'
|
||||
[FIRMWARE]='--firmware'
|
||||
[BIND]='--bind --bind-ro'
|
||||
[SSH_KEY]='--ssh-key'
|
||||
[CONSOLE]='--console'
|
||||
[ARG]='--cpus --ram --vsock-cid -M --machine --uuid--private-users --background --set-credential --load-credential'
|
||||
)
|
||||
|
||||
_init_completion || return
|
||||
|
||||
if __contains_word "$prev" ${OPTS[BOOL]}; then
|
||||
comps='yes no'
|
||||
elif __contains_word "$prev" ${OPTS[PATH]}; then
|
||||
compopt -o nospace -o filenames
|
||||
comps=$(compgen -f -- "$cur" )
|
||||
elif __contains_word "$prev" ${OPTS[FIRMWARE]}; then
|
||||
compopt -o nospace -o filenames
|
||||
comps="list $(compgen -f -- "$cur" )"
|
||||
elif __contains_word "$prev" ${OPTS[BIND]}; then
|
||||
compopt -o nospace -o filenames
|
||||
comps=$(compgen -f -- "${cur}" )
|
||||
elif __contains_word "$prev" ${OPTS[SSH_KEY]}; then
|
||||
comps='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa'
|
||||
elif __contains_word "$prev" ${OPTS[CONSOLE]}; then
|
||||
comps='interactive native gui'
|
||||
elif __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
comps=''
|
||||
else
|
||||
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
complete -F _systemd_vmspawn systemd-vmspawn
|
|
@ -48,7 +48,9 @@
|
|||
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"
|
||||
log-level:"Get/set logging threshold for systemd-resolved"
|
||||
mdns:"Configure per-interface mdns enabled status"
|
||||
monitor:"Monitor DNS queries"
|
||||
nta:"Configure per-interface nta domains"
|
||||
openpgp:"Retrieve openpgp keys for an email"
|
||||
query:"Resolve domain names, IPv4 and IPv6 addresses"
|
||||
|
@ -57,6 +59,7 @@
|
|||
revert:"Revert the per-interfce DNS configuration"
|
||||
service:"Resolve DNS-SD and SRV services"
|
||||
show-cache:"Show the current cache contents"
|
||||
show-server-state:"Show servers state"
|
||||
statistics:"Show resolver statistics"
|
||||
status:"Show the global and per-link DNS settings currently in effect"
|
||||
tlsa:"Query tlsa public keys stored as TLSA resource records"
|
||||
|
@ -81,5 +84,14 @@ _arguments \
|
|||
'--service-address=[Do not resolve address for services]:BOOL:(yes no)' \
|
||||
'--service-txt=[Do not resolve TXT records for services]:BOOL:(yes no)' \
|
||||
'--cname=[Do not follow CNAME redirects]:BOOL:(yes no)' \
|
||||
'--validate=[Do not allow DNSSEC validation]:BOOL:(yes no)' \
|
||||
'--synthesize=[Do not allow synthetic response]:BOOL:(yes no)' \
|
||||
'--cache=[Do not allow response from cache]:BOOL:(yes no)' \
|
||||
'--stale-data=[Do not allow response from cache with stale data]:BOOL:(yes no)' \
|
||||
'--zone=[Do not allow response from locally registered mDNS/LLMNR records]:BOOL:(yes no)' \
|
||||
'--trust-anchor=[Do not allow response from local trust anchor]:BOOL:(yes no)' \
|
||||
'--network=[Do not allow response from network]:BOOL:(yes no)' \
|
||||
'--search=[Do not use search domains]:BOOL:(yes no)' \
|
||||
'--raw=[Dump the answer as binary data]:RAW:(payload packet)' \
|
||||
'--json=[Output as JSON]:JSON:(pretty short off)' \
|
||||
'*::default: _resolvectl_commands'
|
||||
|
|
Loading…
Reference in a new issue