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-images --no-legend --no-pager; machinectl list --no-legend --no-pager; echo ".host") | \
30 { while read a b; do echo " $a"; done; } | sort -u;
34 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
38 [STANDALONE]='--all -a --full --help -h --no-ask-password --no-legend --no-pager --version'
39 [ARG]='--host -H --kill-who -M --machine --property -p --signal -s'
43 [STANDALONE]='list list-images pull-tar pull-raw pull-dkr import-tar import-raw export-tar export-raw list-transfers cancel-transfer'
44 [MACHINES]='status show start login shell enable disable poweroff reboot terminate kill copy-to copy-from image-status show-image clone rename read-only remove set-limit'
47 _init_completion || return
49 for ((i=0; i <= COMP_CWORD; i++)); do
50 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
51 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
57 if __contains_word "$prev" ${OPTS[ARG]}; then
60 comps=$(compgen -A signal)
66 comps=$(compgen -A hostname)
69 comps=$( __get_machines )
75 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
79 if [[ "$cur" = -* ]]; then
80 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
84 if [[ -z $verb ]]; then
87 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
90 elif __contains_word "$verb" ${VERBS[MACHINES]}; then
91 comps=$( __get_machines )
94 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
98 complete -F _machinectl machinectl