1 # networkctl(1) completion -*- shell-script -*-
3 # This file is part of systemd.
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # systemd is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
19 local w word=$1; shift
21 [[ $w = "$word" ]] && return
27 networkctl list --no-legend --no-pager --all | { while read -r a b c; do echo " $b"; done; };
32 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
34 [STANDALONE]='-a --all -h --help --version --no-pager --no-legend'
39 [STANDALONE]='list lldp'
43 _init_completion || return
45 for ((i=0; i < COMP_CWORD; i++)); do
46 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
47 ! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
53 if [[ "$cur" = -* ]]; then
54 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
58 if [[ -z $verb ]]; then
60 elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
62 elif __contains_word "$verb" ${VERBS[LINKS]}; then
63 comps=$( __get_links )
66 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
70 complete -F _networkctl networkctl