Skip to content

Commit d67595b

Browse files
nilninullnavi-desu
authored andcommitted
Added missing options to the zsh completion definitions
Added missing options to the completion definition files for the rc-service, rc-status, and rc-update commands. (Including --user and -U): Added status to the cmd option for rc-service.
1 parent e50e4a8 commit d67595b

File tree

3 files changed

+79
-44
lines changed

3 files changed

+79
-44
lines changed

zsh-completion/_rc-service

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,44 @@ _rc_services() {
44
if [[ -n "${opt_args[(i)-l|--list]}" ]]; then
55
_nothing
66
else
7-
_values 'service' $(rc-service -l)
7+
_values 'service' $(rc-service "${opt_args[(i)-U|--user]}" -l)
88
fi
99
}
1010

1111
_rc_actions() {
1212
local service="${line[1]}"
1313

14-
if [[ -n "${opt_args[(i)-e|--exists|-r|--resolve]}" ]] || ! $(rc-service -e $service) ; then
14+
if [[ -n "${opt_args[(i)-e|--exists|-r|--resolve]}" ]] || ! $(rc-service "${opt_args[(i)-U|--user]}" -e $service) ; then
1515
_nothing
1616
else
17-
local -a actions=(${(f)"$(rc-service -C $service describe 2>&1)"})
17+
local -a actions=(${(f)"$(rc-service "${opt_args[(i)-U|--user]}" -C $service describe 2>&1)"})
1818
shift actions
1919
actions=(${actions# \* })
2020
actions=(${actions/:*})
21-
actions=(stop start restart describe zap ${actions[@]})
21+
actions=(stop start restart status describe zap ${actions[@]})
2222
_describe -V 'action' actions
2323
fi
24-
2524
}
2625

2726
_arguments -C -s \
27+
'(-d --debug)'{-d,--debug}'[set xtrace when running the command]' \
28+
'(-D --nodeps)'{-D,--nodeps}'[ignore dependencies]' \
2829
'(-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]' \
2936
'(-l --list)'{-l,--list}'[list all available services]' \
3037
'(-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]' \
3140
'(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
41+
'(- :)'{-V,--version}'[Display software version]' \
3242
'(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
33-
'(-q --quiet)'{-q,--quiet}'[Run quietly]' \
43+
'(-q --quiet)'{-q,--quiet}'[Run quietly (repeat to suppress errors)]' \
44+
'(-U --user)'{-U,--user}'[Run in user mode]' \
3445
'1:service:_rc_services' \
3546
'2:action:_rc_actions'
3647

zsh-completion/_rc-status

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
#compdef rc-status
22

3-
_arguments -s \
4-
{'(--all)-a','(-a)--all'}'[Show services at all runlevels]' \
5-
{'(--crashed)-c','(-c)--crashed'}'[Show crashed services]' \
6-
{'(--list)-l','(-l)--list'}'[Show list of runlevels]' \
7-
{'(--runlevel)-r','(-r)--runlevel'}'[Show the name of the current runlevel]' \
8-
{'(--servicelist)-s','(-s)--servicelist'}'[Show all services]' \
9-
{'(--unused)-u','(-u)--unused'}'[Show services not assigned to any run level]' \
10-
{'(--help)-h','(-h)--help'}'[Print this help output]' \
11-
{'(--nocolor)-C','(-C)--nocolor'}'[Disable color output]' \
12-
{'(--version)-V','(-V)--version'}'[Display software version]' \
13-
{'(--verbose)-v','(-v)--verbose'}'[Run verbosely]' \
14-
{'(--quiet)-q','(-q)--quiet'}'[Run quietly (Does not affect errors)]'
3+
_rc_runlevels() {
4+
_values runlevels $(rc-status "${opt_args[(i)-U|--user]}" --list)
5+
}
156

16-
_values 'runlevels' $(rc-status --list)
7+
_arguments -s \
8+
'(-a --all)'{-a,--all}'[Show services from all run levels]' \
9+
'(-c --crashed)'{-c,--crashed}'[Show crashed services]' \
10+
'(-f --format)'{-f,--format}'[format status to be parsable (currently arg must be ini)]:format:(ini)' \
11+
'(-i --in-state)'{-i,--in-state}'[Show services which are in this state]:state:(stopped started stopping starting inactive hotplugged failed scheduled crashed)' \
12+
'(-l --list)'{-l,--list}'[Show list of run levels]' \
13+
'(-m --manual)'{-m,--manual}'[Show manually started services]' \
14+
'(-r --runlevel)'{-r,--runlevel}'[Show the name of the current runlevel]' \
15+
'(-s --servicelist)'{-s,--servicelist}'[Show service list]' \
16+
'(-S --supervised)'{-S,--supervised}'[show supervised services]' \
17+
'(-u --unused)'{-u,--unused}'[Show services not assigned to any runlevel]' \
18+
'(- :)'{-h,--help}'[Display this help output]' \
19+
'(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
20+
'(- :)'{-V,--version}'[Display software version]' \
21+
'(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
22+
'(-q --quiet)'{-q,--quiet}'[Run quietly (repeat to suppress errors)]' \
23+
'(-U --user)'{-U,--user}'[Run in user mode]' \
24+
'1:runlevels:_rc_runlevels'
1725

1826
# vim: set et sw=2 ts=2 ft=zsh:

zsh-completion/_rc-update

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,47 @@
11
#compdef rc-update
22

3-
local used_init
4-
used_init=(${=${(M)${(f)"$(rc-update show 2>/dev/null)"}:#*|*[a-z]*}% |*})
3+
_rc_actions() {
4+
_values "actions" \
5+
'add[Add the service to the runlevel or the current one if none given]' \
6+
'del[Delete the service from the runlevel or the current one if none given]' \
7+
'show[Show all enabled services and the runlevels they belong to]'
8+
}
59

6-
if (( CURRENT == 2 )); then
7-
_values "rc-update actions" \
8-
'add[Add script to a runlevel]' \
9-
'del[Delete script from a runlevel]' \
10-
'show[Show scripts in a runlevel]' \
11-
'-a[Process all runlevels]' \
12-
'-s[Stack a runlevel instead of a service]'
13-
elif (( CURRENT == 3 )); then
14-
case "$words[2]" in
15-
add)
16-
_values "service" $(rc-service --list)
17-
;;
18-
del)
19-
_values "service" $used_init
20-
;;
21-
show)
22-
_values "runlevels" $(rc-status --list) \
23-
'-v[Show all service scripts]' \
24-
'--verbose[Show all service scripts]'
25-
;;
10+
_rc_service() {
11+
case $line[1] in
12+
add)
13+
_values "service" $(rc-service "${opt_args[(i)-U|--user]}" --list)
14+
;;
15+
del)
16+
_values "service" ${=${(M)${(f)"$(rc-update ${opt_args[(i)-U|--user]} show 2>/dev/null)"}:#*|*[a-z]*}% |*}
17+
;;
18+
show)
19+
_values "runlevels" $(rc-status "${opt_args[(i)-U|--user]}" --list)
20+
_values "options" '(-v --verbose)'{-v,--verbose}'[Show all service scripts]'
21+
;;
2622
esac
27-
elif (( CURRENT == 4 )); then
28-
_values "runlevels" $(rc-status --list)
29-
fi
23+
}
24+
25+
_rc_runlevels() {
26+
if [[ $line[1] == show ]]; then
27+
_nothing
28+
else
29+
_values "runlevels" $(rc-status "${opt_args[(i)-U|--user]}" --list)
30+
fi
31+
}
32+
33+
_arguments -C -s \
34+
'(-a --all)'{-a,--all}'[Process all runlevels]' \
35+
'(-s --stack)'{-s,--stack}'[Stack a runlevel instead of a service]' \
36+
'(-u --update)'{-u,--update}'[Force an update of the dependency tree]' \
37+
'(- :)'{-h,--help}'[Display this help output]' \
38+
'(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
39+
'(- :)'{-V,--version}'[Display software version]' \
40+
'(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
41+
'(-q --quiet)'{-q,--quiet}'[Run quietly (repeat to suppress errors)]' \
42+
'(-U --user)'{-U,--user}'[Run in user mode]' \
43+
'1:actions:_rc_actions' \
44+
'2:service:_rc_service' \
45+
'3:runlevels:_rc_runlevels'
3046

3147
# vim: set et sw=2 ts=2 ft=zsh:

0 commit comments

Comments
 (0)