Debian Codegraph @

zsh-completion/_rc-service

raw
1 #compdef rc-service
2
3 _rc_services() {
4 if [[ -n "${opt_args[(i)-l|--list]}" ]]; then
5 _nothing
6 else
7 _values 'service' $(rc-service "${opt_args[(i)-U|--user]}" -l)
8 fi
9 }
10
11 _rc_actions() {
12 local service="${line[1]}"
13
14 if [[ -n "${opt_args[(i)-e|--exists|-r|--resolve]}" ]] || ! $(rc-service "${opt_args[(i)-U|--user]}" -e $service) ; then
15 _nothing
16 else
17 local -a actions=(${(f)"$(rc-service "${opt_args[(i)-U|--user]}" -C $service describe 2>&1)"})
18 shift actions
19 actions=(${actions# \* })
20 actions=(${actions/:*})
21 actions=(stop start restart status describe zap ${actions[@]})
22 _describe -V 'action' actions
23 fi
24 }
25
26 _arguments -C -s \
27 '(-d --debug)'{-d,--debug}'[set xtrace when running the command]' \
28 '(-D --nodeps)'{-D,--nodeps}'[ignore dependencies]' \
29 '(-e --exists)'{-e,--exists}'[tests if the service exists or not]' \
30 '(-c --ifcrashed)'{-c,--ifcrashed}'[if the service is crashed run the command]' \
31 '(-i --ifexists)'{-i,--ifexists}'[if the service exists run the command]' \
32 '(-I --ifinactive)'{-I,--ifinactive}'[if the service is inactive run the command]' \
33 '(-N --ifnotstarted)'{-N,--ifnotstarted}'[if the service is not started run the command]' \
34 '(-s --ifstarted)'{-s,--ifstarted}'[if the service is started run the command]' \
35 '(-S --ifstopped)'{-S,--ifstopped}'[if the service is stopped run the command]' \
36 '(-l --list)'{-l,--list}'[list all available services]' \
37 '(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \
38 '(-Z --dry-run)'{-Z,--dry-run}'[dry run (show what would happen)]' \
39 '(- :)'{-h,--help}'[Display this help output]' \
40 '(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
41 '(- :)'{-V,--version}'[Display software version]' \
42 '(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
43 '(-q --quiet)'{-q,--quiet}'[Run quietly (repeat to suppress errors)]' \
44 '(-U --user)'{-U,--user}'[Run in user mode]' \
45 '1:service:_rc_services' \
46 '2:action:_rc_actions'
47
48 # vim: set et sw=2 ts=2 ft=zsh: