components/zsh/Completion/Solaris/Command/_svcadm
author Danek Duvall <danek.duvall@oracle.com>
Fri, 10 Jan 2014 13:37:47 -0800
branchs11-update
changeset 2892 0309f67d63d6
parent 837 3496f33edfbb
permissions -rw-r--r--
18037934 zsh completion functions need updating to match 11.1

#compdef svcadm

_svcadm() {
	local context state line subcmds
	typeset -A opt_args

	subcmds=( enable disable restart refresh mark delegate clear milestone )

	if [[ $service == "svcadm" ]]; then
		_arguments -C -A "-*" \
			'-v[Print actions verbosely]' \
			'*::command:->subcmd' && return 0

		if (( CURRENT == 1 )); then
			_wanted commands expl 'svcadm subcommand' compadd -a subcmds
			return
		fi
		service="$words[1]"
		curcontext="${curcontext%:*}=$service:"
	fi

	case $service in
	(enable)
		_arguments -A "-*" \
			'-r[Recursively enable dependencies]' \
			'-s[Synchronous mode: wait for service to come online]' \
			'-T[Timeout for synchronous mode]:seconds:' \
			'-t[State change is temporary]' \
			'*:instance FMRI:_svcs_fmri -i'
		;;

	(disable)
		_arguments -A "-*" \
			'-s[Synchronous mode: wait for service to become disabled]' \
			'-T[Timeout for synchronous mode]:seconds:' \
			'-t[State change is temporary]' \
			'*:instance FMRI:_svcs_fmri -i'
		;;

	(mark)
		_arguments -A "-*" \
			'-I[Change state immediately]' \
			"-s[Synchronous mode: wait for service to reach the new state]" \
			'-T[Timeout for synchronous mode]:seconds:' \
			'-t[State change is temporary]' \
			':state:(degraded maintenance)' \
			':instance FMRI:_svcs_fmri -i'
		;;

	(restart|refresh|clear)
		_arguments \
			"-s[Synchronous mode: wait for service to $service]" \
			'-T[Timeout for synchronous mode]:seconds:' \
			'*:instance FMRI:_svcs_fmri -i'
		;;

	(delegate)
		_arguments -A "-*" \
			'-s[Synchronous mode: wait for instances to come online]' \
			'-T[Timeout for synchronous mode]:seconds:' \
			':restarter FMRI:_svcs_fmri -r' \
			'*:FMRI:_svcs_fmri -i'
		;;

	(milestone)
		_arguments -A "-*" \
			'-d[Make milestone the default]' \
			'-s[Synchronous mode: wait for the transition to the new milestone]' \
			'-T[Timeout for synchronous mode]:seconds:' \
			'*:milestone FMRI:_svcs_fmri -m'
		;;

	(*)
		_message "unknown svcadm subcommand: $service"
	esac
}

_svcadm "$@"