26763: fix problem on failed cd -s to relative path
[zsh.git] / Completion / Solaris / Command / _svccfg
blob5d1bf358a5a56b03e4c8bace03f5d669f176cb69
1 #compdef svccfg
3 _svccfg_properties() {
4         local -a props fmris
5         local fmri="$argv[$#]"
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
14         # Get all the property names for the FMRI
15         props=( ${${${(f)"$(svccfg -s $fmri describe)"}:# *}%% *} )
17         _multi_parts "$expl[@]" - / props
20 _svccfg() {
21         local context state line subcmds
22         typeset -A opt_args
24         subcmds=( apply describe extract import validate export inventory delete addpropvalue delpropvalue )
26         if [[ $service == "svccfg" ]]; then
27                 _arguments -s \
28                         '-?[Help]' \
29                         '-v[Verbose]' \
30                         '-s[FMRI on which to operate]:fmri:_svcs_fmri -c' \
31                         - set1 \
32                         '-f[Read commands from file]:command file:_files' \
33                         - set2 \
34                         '*::command:->subcmd' && return 0
36                 if (( CURRENT == 1 )); then
37                         _wanted commands expl 'svccfg subcommand' compadd -a subcmds
38                         return
39                 fi
40                 service="$words[1]"
41                 curcontext="${curcontext%:*}=$service:"
42         fi
44         case $service in
45         (import)
46                 _arguments \
47                         '-V[Verify property updates]' \
48                         ':file:_files'
49                 ;;
51         (apply|inventory)
52                 _files
53                 ;;
55         (validate)
56                 _alternative 'files:file:_files' 'fmris:fmri:_svc_fmri -c'
57                 ;;
59         (export)
60                 _svcs_fmri -c
61                 ;;
63         (delete)
64                 _arguments \
65                         '-f[Force deletion if online or degraded]' \
66                         '*:FMRI:_svcs_fmri -c'
67                 ;;
69         (describe)
70                 local fmri=$opt_args[-s]
71                 _arguments -A "-*" \
72                         '-v[Give all information]' \
73                         '-t[Show only template data]' \
74                         ":property group or property:_svccfg_properties $fmri"
75                 ;;
77         (extract)
78                 ;;
80         (*)
81                 _message "unknown svccfg subcommand: $service"
82                 ;;
83         esac
86 _svccfg "$@"
88 # vi:tw=0