#compdef cyclog delegate-control-group-to emergency-login envdir export-to-rsyslog fifo-listen follow-log-directories getuidgid local-reaper nosh open-controlling-tty move-to-control-group oom-kill-protect pipe plug-and-play-event-handler read-conf recordio tcpserver ttylogin-starter ucspi-socket-rules-check umask unshare userenv-fromenv -P (app|pre)pendpath (back|fore)ground (hard|soft|u)limit (set|unset|user|machine|clear|print)env (tcp|udp|netlink-*|local-*)-socket-(listen|accept) (tcp|udp|local-stream)-socket-connect ch(root|dir) env(uid|)gid fd(move|redir) find-*-jvm l(ogin|ine)-banner login-pro(cess|mpt) make-(private|read-only)-fs monitor(ed-fsck|fcsk-progress) pty-(run|get-tty) set(env|login|(uid|)gid(|-fromenv)|lock|sid|pgrp|-control-group-knob|-mount-object) tai64n(|local) time-(env-(add|set(-if-earlier|)|unset-if-later)|pause-until|print-tai64n) vc-(get-tty|reset)
## **************************************************************************
## For copyright and licensing terms, see the file named COPYING.
## **************************************************************************
#
# Z Shell command-line completion

function _boolean()
{
	local -a types
	types=(
	'true'
	'false'
	'on:TRUE'
	'off:FALSE'
	'yes:TRUE'
	'no:FALSE'
	)
	_describe -t boolean 'types' types
}

function _users()
{
	local expl users

	if zstyle -a ":completion:${curcontext}:users" users users
	then
		_wanted users expl user compadd "$@" -a - users
	else
		_wanted users expl user compadd "$@" -k - userdirs
	fi
}

function _nosh()
{
	local lstate state next
	local -a common
	common=(-s '--help[Display option help]' '--usage[Display option usage]')
	next='*:::next prog:_normal'

	case "${service}" in
		cyclog)
			_arguments -A '-*' $common '*:log directories:_directories' -- ;;
		follow-log-directories)
			_arguments -A '-*' $common '*:follow directories:_directories' -- ;;
		setenv|(app|pre)pendpath)
			_arguments -A '-*' $common '1:variable:' '2:value:' $next -- ;;
		time-env-add)
			_arguments -A '-*' $common '1:variable:' '2:offset:' $next -- ;;
		time-env-(set|(-if-earlier|)|unset-if-later))
			_arguments -A '-*' $common '1:variable:' '2:timestamp:' $next -- ;;
		time-pause-until)
			_arguments -A '-*' $common '1:time specification:' $next -- ;;
		time-print-tai64n)
			_arguments -A '-*' $common '1:timestamp:' $next -- ;;
		unsetenv)
			_arguments -A '-*' $common '1:variable:' $next -- ;;
		setlock)
			_arguments -A '-*' $common '1:lock file:_files' $next -- ;;
		login-banner)
			_arguments -A '-*' $common '1:banner file:_files' $next -- ;;
		read-conf)
			_arguments -A '-*' $common '1:conf file:_files' $next -- ;;
		vc-get-tty)
			_arguments -A '-*' $common '1:virtual terminal device file:_files' $next -- ;;
		ch(root|dir)|envdir|export-to-rsyslog)
			_arguments -A '-*' $common '1:directory:_directories' $next -- ;;
		setlogin|(env|set)uidgid)
			_arguments -A '-*' $common '1:account:_users' $next -- ;;
		delegate-control-group-to)
			_arguments -A '-*' $common '1:account:_users' -- ;;
		umask)
			_arguments -A '-*' $common '1:mask:' $next -- ;;
		oom-kill-protect)
			_arguments -A '-*' $common '1:level:' $next -- ;;
		move-to-control-group)
			_arguments -A '-*' $common '1:group:' $next -- ;;
		set-mount-object)
			_arguments -A '-*' $common '1:state:' '2:directory:_directories' $next -- ;;
		line-banner)
			_arguments -A '-*' $common '1:banner:' $next -- ;;
		fdredir)
			_arguments -A '-*' $common '1:file descriptor:' '2:file:_files' $next -- ;;
		(env|set)gid)
			_arguments -A '-*' $common '1:group:' $next -- ;;
		(fifo|local-*-socket)-listen)
			_arguments -A '-*' $common '1:path:_files' $next -- ;;
		(tcp|udp)-socket-(listen|connect)|tcpserver)
			_arguments -A '-*' $common '1:host:' '2:service:' $next -- ;;
		netlink-*-socket-listen)
			_arguments -A '-*' $common '1:protocol:' '2:multicast group:' $next -- ;;
		local-reaper)
			_arguments -S $common '1:enable value:_boolean' $next -- ;;
		getuidgid|(set(uid|)gid|userenv)-fromenv|fdmove|find-*-jvm|(hard|soft|u)limit|(machine|user|clear)env|(open-controlling|vc-reset|pty-get)-tty|*-socket-accept|set(sid|pgrp)|unshare|login-pro(cess|mpt)|pty-run|ucspi-socket-rules-check|recordio|make-(private|read-only)-fs|ucspi-socket-rules-check|pipe|(back|fore)ground)
			_arguments -A '-*' $common $next -- ;;
		set-control-group-knob)
			_arguments -A '-*' $common '1:group:' '2:knob:' -- ;;
		printenv)
			_arguments -A '-*' $common '1:variable:_parameters -g "*export*"' -- ;;
		nosh)
			_arguments  '1:script:_files' ;;
	# TODO: monitored-fsck
		*)
			_arguments -A '-*' $common -- ;;
	esac
}

_nosh "$@"
