| 1 |
# Copyright (c) 2017 The OpenRC Authors. |
| 2 |
# See the Authors file at the top-level directory of this distribution and |
| 3 |
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS |
| 4 |
# |
| 5 |
# This file is part of OpenRC. It is subject to the license terms in |
| 6 |
# the LICENSE file found in the top-level directory of this |
| 7 |
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE |
| 8 |
# This file may not be copied, modified, propagated, or distributed |
| 9 |
# except according to the terms contained in the LICENSE file. |
| 10 |
|
| 11 |
# |
| 12 |
# rc-update completion command |
| 13 |
# |
| 14 |
_rc_update() |
| 15 |
{ |
| 16 |
local cur show |
| 17 |
COMPREPLY=() |
| 18 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 19 |
if [[ $COMP_CWORD -eq 1 ]]; then |
| 20 |
if [[ "${cur}" == -* ]]; then |
| 21 |
COMPREPLY=($(compgen -W '-a -d -s' -- ${cur})) |
| 22 |
else |
| 23 |
COMPREPLY=($(compgen -W 'add del show' ${cur})) |
| 24 |
fi |
| 25 |
else |
| 26 |
if [[ "${COMP_WORDS[1]}" == "show" ]] || [[ "${COMP_WORDS[1]}" == "-s" ]]; then |
| 27 |
show="TRUE" |
| 28 |
fi |
| 29 |
if ([[ $COMP_CWORD -eq 3 ]] && [[ -z "$show" ]]) || \ |
| 30 |
([[ $COMP_CWORD -eq 2 ]] && [[ -n "$show" ]]); then |
| 31 |
COMPREPLY=($(compgen -W "$(rc-status --list)" -- $cur)) |
| 32 |
elif [[ $COMP_CWORD -eq 2 ]]; then |
| 33 |
COMPREPLY=($(compgen -W "$(rc-service --list)" $cur)) |
| 34 |
elif [[ ${#COMP_WORDS[*]} -gt 2 ]] ; then |
| 35 |
COMPREPLY=($(compgen -W "$(rc-status --list)" -- $cur)) |
| 36 |
else |
| 37 |
unset COMPREPLY |
| 38 |
fi |
| 39 |
fi |
| 40 |
return 0 |
| 41 |
} && |
| 42 |
complete -F _rc_update rc-update |