1 # machinectl(1) completion -*- shell-script -*-
3 # This file is part of systemd.
5 # Copyright 2014 Thomas H.P. Andersen
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 local w word=$1; shift
23 [[ $w = "$word" ]] && return
29 machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
33 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
37 [STANDALONE]='--all -a --full --help -h --no-ask-password --no-legend --no-pager --version'
38 [ARG]='--host -H --kill-who -M --machine --property -p --signal -s'
43 [MACHINES]='status show terminate kill reboot login'
46 _init_completion || return
48 for ((i=0; i <= COMP_CWORD; i++)); do
49 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
50 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
56 if __contains_word "$prev" ${OPTS[ARG]}; then
59 comps=$(compgen -A signal)
65 comps=$(compgen -A hostname)
68 comps=$( __get_machines )
74 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
78 if [[ "$cur" = -* ]]; then
79 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
83 if [[ -z $verb ]]; then
86 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
89 elif __contains_word "$verb" ${VERBS[MACHINES]}; then
90 comps=$( __get_machines )
93 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
97 complete -F _machinectl machinectl