zsh-completion: _rc-service fix flag/command combinations
- handle `rc-service -<flag> <service> <action>` correctly This is for #285.
This commit is contained in:
parent
50d77a4e5d
commit
77f09900a2
@ -1,27 +1,32 @@
|
|||||||
#compdef rc-service
|
#compdef rc-service
|
||||||
|
|
||||||
if (( CURRENT == 2 )); then
|
_rc_services() {
|
||||||
_arguments -s \
|
if [[ -n "${opt_args[(i)-l|--list]}" ]]; then
|
||||||
'(-e --exists)'{-e,--exists}"[tests if the service exists or not]" \
|
_nothing
|
||||||
'(-l --list)'{-l,--list}'[list all available services]' \
|
else
|
||||||
'(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \
|
_values 'service' $(rc-service -l)
|
||||||
'(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
|
fi
|
||||||
'(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
|
}
|
||||||
'(-q --quiet)'{-q,--quiet}'[Run quietly]'
|
|
||||||
_values "service" $(rc-service --list)
|
_rc_actions() {
|
||||||
else
|
local service="${line[1]}"
|
||||||
case $words[2] in
|
|
||||||
-e|--exists|-r|--resolve)
|
if [[ -n "${opt_args[(i)-e|--exists|-r|--resolve]}" ]] || ! $(rc-service -e $service) ; then
|
||||||
(( CURRENT > 3 )) && return 0
|
_nothing
|
||||||
_values "service" $(rc-service --list)
|
else
|
||||||
;;
|
_values 'action' stop start restart describe zap
|
||||||
-*)
|
fi
|
||||||
return 0
|
|
||||||
;;
|
}
|
||||||
*)
|
|
||||||
_values "action" stop start restart describe zap
|
_arguments -C -s \
|
||||||
;;
|
'(-e --exists)'{-e,--exists}'[tests if the service exists or not]' \
|
||||||
esac
|
'(-l --list)'{-l,--list}'[list all available services]' \
|
||||||
fi
|
'(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \
|
||||||
|
'(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
|
||||||
|
'(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
|
||||||
|
'(-q --quiet)'{-q,--quiet}'[Run quietly]' \
|
||||||
|
'1:service:_rc_services' \
|
||||||
|
'2:action:_rc_actions'
|
||||||
|
|
||||||
# vim: set et sw=2 ts=2 ft=zsh:
|
# vim: set et sw=2 ts=2 ft=zsh:
|
||||||
|
Loading…
Reference in New Issue
Block a user