1 #compdef svccfg |
|
2 |
|
3 _svccfg_properties() { |
|
4 local -a props fmris |
|
5 local fmri="$argv[$#]" |
|
6 |
|
7 # If There's more than one possible FMRI, bail |
|
8 fmris=( ${(f)"$(svcs -H -o fmri $fmri)"} ) |
|
9 if [[ $#fmris -gt 1 ]]; then |
|
10 _message "'$fmri' is ambiguous" |
|
11 return 1 |
|
12 fi |
|
13 |
|
14 # Get all the property names for the FMRI |
|
15 props=( ${${${(f)"$(svccfg -s $fmri describe)"}:# *}%% *} ) |
|
16 |
|
17 _multi_parts "$expl[@]" - / props |
|
18 } |
|
19 |
|
20 _svccfg() { |
|
21 local context state line subcmds |
|
22 typeset -A opt_args |
|
23 |
|
24 # Subcommands that don't make sense on the commandline are missing |
|
25 subcmds=( |
|
26 apply export extract import inventory validate |
|
27 add delete list |
|
28 addpg addpropvalue delcust delpg delprop delpropvalue describe |
|
29 editprop listpg listprop listcust setenv setprop unsetenv |
|
30 setnotify listnotify delnotify |
|
31 listsnap revert selectsnap |
|
32 refresh |
|
33 ) |
|
34 |
|
35 if [[ $service == "svccfg" ]]; then |
|
36 _arguments -s \ |
|
37 '-?[help]' \ |
|
38 '-v[verbose]' \ |
|
39 '-s[FMRI on which to operate]:fmri:_svcs_fmri -c' \ |
|
40 - set1 \ |
|
41 '-f[read commands from file]:command file:_files' \ |
|
42 - set2 \ |
|
43 '*::command:->subcmd' && return 0 |
|
44 |
|
45 if (( CURRENT == 1 )); then |
|
46 _wanted commands expl 'svccfg subcommand' compadd -a subcmds |
|
47 return |
|
48 fi |
|
49 service="$words[1]" |
|
50 curcontext="${curcontext%:*}=$service:" |
|
51 fi |
|
52 |
|
53 case $service in |
|
54 (import) |
|
55 _arguments \ |
|
56 '-V[verify property updates]' \ |
|
57 ':file:_files' |
|
58 ;; |
|
59 |
|
60 (apply|inventory) |
|
61 _files |
|
62 ;; |
|
63 |
|
64 (validate) |
|
65 _alternative 'files:file:_files' 'fmris:fmri:_svc_fmri -c' |
|
66 ;; |
|
67 |
|
68 (export) |
|
69 _svcs_fmri -c |
|
70 ;; |
|
71 |
|
72 (delete) |
|
73 _arguments \ |
|
74 '-f[force deletion if online or degraded]' \ |
|
75 '*:FMRI:_svcs_fmri -c' |
|
76 ;; |
|
77 |
|
78 (describe) |
|
79 local fmri=$opt_args[-s] |
|
80 _arguments -A "-*" \ |
|
81 '-v[give all information]' \ |
|
82 '-t[show only template data]' \ |
|
83 ":property group or property:_svccfg_properties $fmri" |
|
84 ;; |
|
85 |
|
86 (extract|add|delete|list|addpg|addpropvalue|delcust|delpg|delprop) |
|
87 ;; |
|
88 |
|
89 (delpropvalue|editprop|listpg|listprop|listcust|setenv|setprop|unsetenv) |
|
90 ;; |
|
91 |
|
92 (setnotify|listnotify|delnotify|listsnap|revert|selectsnap|refresh) |
|
93 ;; |
|
94 |
|
95 (*) |
|
96 _message "unknown svccfg subcommand: $service" |
|
97 ;; |
|
98 esac |
|
99 } |
|
100 |
|
101 _svccfg "$@" |
|
102 |
|
103 # vi:tw=0 |
|