diff options
Diffstat (limited to 'shell-completion')
l--------- | shell-completion/Makefile | 1 | ||||
-rw-r--r-- | shell-completion/bash/.gitignore | 1 | ||||
l--------- | shell-completion/bash/Makefile | 1 | ||||
-rw-r--r-- | shell-completion/bash/loginctl | 14 | ||||
-rw-r--r-- | shell-completion/bash/meson.build | 58 | ||||
-rw-r--r-- | shell-completion/bash/resolvectl | 182 | ||||
-rw-r--r-- | shell-completion/zsh/.gitignore | 1 | ||||
l--------- | shell-completion/zsh/Makefile | 1 | ||||
-rw-r--r-- | shell-completion/zsh/_elogind-inhibit | 1 | ||||
-rw-r--r-- | shell-completion/zsh/_loginctl | 1 | ||||
-rw-r--r-- | shell-completion/zsh/meson.build | 53 |
11 files changed, 303 insertions, 11 deletions
diff --git a/shell-completion/Makefile b/shell-completion/Makefile deleted file mode 120000 index bd1047548..000000000 --- a/shell-completion/Makefile +++ /dev/null @@ -1 +0,0 @@ -../src/Makefile
\ No newline at end of file diff --git a/shell-completion/bash/.gitignore b/shell-completion/bash/.gitignore deleted file mode 100644 index 016e09d1e..000000000 --- a/shell-completion/bash/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/systemctl diff --git a/shell-completion/bash/Makefile b/shell-completion/bash/Makefile deleted file mode 120000 index d0b0e8e00..000000000 --- a/shell-completion/bash/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile
\ No newline at end of file diff --git a/shell-completion/bash/loginctl b/shell-completion/bash/loginctl index 776eca4e6..1f5b46620 100644 --- a/shell-completion/bash/loginctl +++ b/shell-completion/bash/loginctl @@ -1,8 +1,9 @@ # loginctl(1) completion -*- shell-script -*- +# SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # -# Copyright 2010 Ran Benita +# Copyright © 2010 Ran Benita # # 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 @@ -33,10 +34,11 @@ _loginctl () { local i verb comps local -A OPTS=( - [STANDALONE]='--all -a --help -h --no-pager --privileged -P --version - --no-legend --no-ask-password -l --full' - [ARG]='--host -H --kill-who --property -p --signal -s --machine' - ) + [STANDALONE]='--all -a --help -h --no-pager --version + --no-legend --no-ask-password -l --full --value' + [ARG]='--host -H --kill-who --property -p --signal -s -M --machine + -n --lines -o --output' + ) if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in @@ -68,7 +70,7 @@ _loginctl () { [SESSIONS]='session-status show-session activate lock-session unlock-session terminate-session kill-session' [USERS]='user-status show-user enable-linger disable-linger terminate-user kill-user' [SEATS]='seat-status show-seat terminate-seat' - [STANDALONE]='list-sessions list-users list-seats flush-devices' + [STANDALONE]='list-sessions lock-sessions unlock-sessions list-users list-seats flush-devices' [ATTACH]='attach' ) diff --git a/shell-completion/bash/meson.build b/shell-completion/bash/meson.build new file mode 100644 index 000000000..fdc77cc4a --- /dev/null +++ b/shell-completion/bash/meson.build @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: LGPL-2.1+ + +bashcompletiondir = get_option('bashcompletiondir') +if bashcompletiondir == '' + bash_completion = dependency('bash-completion', required : false) + if bash_completion.found() + bashcompletiondir = bash_completion.get_pkgconfig_variable('completionsdir') + else + bashcompletiondir = join_paths(datadir, 'bash-completion/completions') + endif + + message('bash completions: @0@'.format(bashcompletiondir)) +endif + +if bashcompletiondir != 'no' +#if 0 /// elogind has a *very* short list for this... +# bash_systemctl = configure_file( +# input : 'systemctl.in', +# output : 'systemctl', +# configuration : substs) +# +# items = [['busctl', ''], +# ['journalctl', ''], +# ['systemd-analyze', ''], +# ['systemd-cat', ''], +# ['systemd-cgls', ''], +# ['systemd-cgtop', ''], +# ['systemd-delta', ''], +# ['systemd-detect-virt', ''], +# ['systemd-nspawn', ''], +# ['systemd-path', ''], +# ['systemd-run', ''], +# ['udevadm', ''], +# ['kernel-install', ''], +# [bash_systemctl, ''], +# ['bootctl', 'ENABLE_EFI'], +# ['coredumpctl', 'ENABLE_COREDUMP'], +# ['hostnamectl', 'ENABLE_HOSTNAMED'], +# ['localectl', 'ENABLE_LOCALED'], +# ['loginctl', 'ENABLE_LOGIND'], +# ['machinectl', 'ENABLE_MACHINED'], +# ['networkctl', 'ENABLE_NETWORKD'], +# ['portablectl', 'ENABLE_PORTABLED'], +# ['resolvectl', 'ENABLE_RESOLVE'], +# ['systemd-resolve', 'ENABLE_RESOLVE'], +# ['timedatectl', 'ENABLE_TIMEDATED'], +#else + items = [['loginctl', ''], +#endif // 0 + ] + + foreach item : items + if item[1] == '' or conf.get(item[1]) == 1 + install_data(item[0], + install_dir : bashcompletiondir) + endif + endforeach +endif diff --git a/shell-completion/bash/resolvectl b/shell-completion/bash/resolvectl new file mode 100644 index 000000000..367f9c7c8 --- /dev/null +++ b/shell-completion/bash/resolvectl @@ -0,0 +1,182 @@ +# resolvectl(1) completion -*- shell-script -*- +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is part of elogind. +# +# +# elogind 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. +# +# elogind 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 elogind; If not, see <http://www.gnu.org/licenses/>. + +__contains_word () { + local w word=$1; shift + for w in "$@"; do + [[ $w = "$word" ]] && return + done +} + +__get_interfaces(){ + { cd /sys/class/net && echo *; } | \ + while read -d' ' -r name; do + [[ "$name" != "lo" ]] && echo "$name" + done +} + +_resolvectl() { + local i comps verb name + local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} + local -A OPTS=( + [STANDALONE]='-h --help --version --no-pager -4 -6 + --service-address=no --service-txt=no + --cname=no --search=no --legend=no' + [ARG]='-i --interface -p --protocol -t --type -c --class --raw' + ) + local -A VERBS=( + [DOMAIN]='query service openpgp' + [FAMILY]='tlsa' + [STATUS]='status' + [LINK]='revert dns domain nta' + [RESOLVE]='llmnr mdns' + [DNSSEC]='dnssec' + [DNSOVERTLS]='dnsovertls' + [STANDALONE]='statistics reset-statistics flush-caches reset-server-features' + ) + local -A ARGS=( + [FAMILY]='tcp udp sctp' + [RESOLVE]='yes no resolve' + [DNSSEC]='yes no allow-downgrade' + [DNSOVERTLS]='no opportunistic' + ) + local interfaces=$( __get_interfaces ) + + if __contains_word "$prev" ${OPTS[ARG]}; then + case $prev in + --interface|-i) + comps="$interfaces" + ;; + --protocol|-p|--type|-t|--class|-c) + comps=$( resolvectl --legend=no "$prev" help; echo help ) + ;; + --raw) + comps="payload packet" + ;; + esac + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 + fi + + if [[ "$cur" = -* ]]; then + COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) + return 0 + fi + + for ((i=0; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} && + ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + verb=${COMP_WORDS[i]} + break + fi + done + + if [[ -z $verb ]]; then + comps="${VERBS[*]}" + + elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[DOMAIN]}; then + comps='' + + elif __contains_word "$verb" ${VERBS[STATUS]}; then + comps="$interfaces" + + elif __contains_word "$verb" ${VERBS[FAMILY]}; then + for ((i++; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" ${ARGS[FAMILY]} && + ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + name=${COMP_WORDS[i]} + break; + fi + done + if [[ -z $name ]]; then + comps=${ARGS[FAMILY]} + else + comps="" + fi + + elif __contains_word "$verb" ${VERBS[LINK]} ${VERBS[RESOLVE]} ${VERBS[DNSSEC]} ${VERBS[DNSOVERTLS]}; then + for ((i++; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" $interfaces && + ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + name=${COMP_WORDS[i]} + break; + fi + done + + if [[ -z $name ]]; then + comps="$interfaces" + + elif __contains_word "$verb" ${VERBS[RESOLVE]}; then + name= + for ((i++; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" ${ARGS[RESOLVE]} && + ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + name=${COMP_WORDS[i]} + break; + fi + done + + if [[ -z $name ]]; then + comps=${ARGS[RESOLVE]} + else + comps='' + fi + + elif __contains_word "$verb" ${VERBS[DNSSEC]}; then + name= + for ((i++; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" ${ARGS[DNSSEC]} && + ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + name=${COMP_WORDS[i]} + break; + fi + done + + if [[ -z $name ]]; then + comps=${ARGS[DNSSEC]} + else + comps='' + fi + + elif __contains_word "$verb" ${VERBS[DNSOVERTLS]}; then + name= + for ((i++; i < COMP_CWORD; i++)); do + if __contains_word "${COMP_WORDS[i]}" ${ARGS[DNSOVERTLS]} && + ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then + name=${COMP_WORDS[i]} + break; + fi + done + + if [[ -z $name ]]; then + comps=${ARGS[DNSOVERTLS]} + else + comps='' + fi + + else + comps='' + fi + fi + + COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) + return 0 +} + +complete -F _resolvectl resolvectl diff --git a/shell-completion/zsh/.gitignore b/shell-completion/zsh/.gitignore deleted file mode 100644 index 75f13ad6d..000000000 --- a/shell-completion/zsh/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/_systemctl diff --git a/shell-completion/zsh/Makefile b/shell-completion/zsh/Makefile deleted file mode 120000 index d0b0e8e00..000000000 --- a/shell-completion/zsh/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile
\ No newline at end of file diff --git a/shell-completion/zsh/_elogind-inhibit b/shell-completion/zsh/_elogind-inhibit index 1b3247b2c..764713e28 100644 --- a/shell-completion/zsh/_elogind-inhibit +++ b/shell-completion/zsh/_elogind-inhibit @@ -1,4 +1,5 @@ #compdef systemd-inhibit +# SPDX-License-Identifier: LGPL-2.1+ _systemd_inhibit_command(){ if (( CURRENT == 1 )); then diff --git a/shell-completion/zsh/_loginctl b/shell-completion/zsh/_loginctl index 6f6ff6e31..03dde9a89 100644 --- a/shell-completion/zsh/_loginctl +++ b/shell-completion/zsh/_loginctl @@ -1,4 +1,5 @@ #compdef loginctl +# SPDX-License-Identifier: LGPL-2.1+ _loginctl_all_sessions() { local session description diff --git a/shell-completion/zsh/meson.build b/shell-completion/zsh/meson.build new file mode 100644 index 000000000..806ea8850 --- /dev/null +++ b/shell-completion/zsh/meson.build @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: LGPL-2.1+ + +zshcompletiondir = get_option('zshcompletiondir') +if zshcompletiondir == '' + zshcompletiondir = join_paths(datadir, 'zsh/site-functions') + + message('zsh completions: @0@'.format(zshcompletiondir)) +endif + +if zshcompletiondir != 'no' +#if 0 /// elogind has a *very* short list for this... +# zsh_systemctl = configure_file( +# input : '_systemctl.in', +# output : '_systemctl', +# configuration : substs) +# +# items = [['_busctl', ''], +# ['_journalctl', ''], +# ['_systemd-analyze', ''], +# ['_systemd-delta', ''], +# ['_systemd-nspawn', ''], +# ['_systemd', ''], +# ['_systemd-run', ''], +# ['_udevadm', ''], +# ['_kernel-install', ''], +# ['_sd_hosts_or_user_at_host', ''], +# ['_sd_outputmodes', ''], +# ['_sd_unit_files', ''], +# ['_sd_machines', ''], +# [zsh_systemctl, ''], +# ['_bootctl', 'ENABLE_EFI'], +# ['_coredumpctl', 'ENABLE_COREDUMP'], +# ['_hostnamectl', 'ENABLE_HOSTNAMED'], +# ['_localectl', 'ENABLE_LOCALED'], +# ['_loginctl', 'ENABLE_LOGIND'], +# ['_machinectl', 'ENABLE_MACHINED'], +# ['_networkctl', 'ENABLE_NETWORKD'], +# ['_systemd-inhibit', 'ENABLE_LOGIND'], +# ['_systemd-resolve', 'ENABLE_RESOLVE'], +# ['_systemd-tmpfiles', 'ENABLE_TMPFILES'], +# ['_timedatectl', 'ENABLE_TIMEDATED'], +#else + items = [['_loginctl', ''], +#endif // 0 + ] + + foreach item : items + if item[1] == '' or conf.get(item[1]) == 1 + install_data(item[0], + install_dir : zshcompletiondir) + endif + endforeach +endif |