#compdef makoctl

local -a makoctl_cmds

makoctl_cmds=(
	'dismiss:Dismiss notification (first by default)'
	'restore:Restore the most recently expired notification from the history buffer'
	'invoke:Invoke an action on the first notification. If action is not specified, invoke the default action'
	'menu:Use a program to select one action to be invoked on the notification'
	'list:Retrieve a list of current notifications'
	'history:Retrieve a list of dismissed notifications'
	'reload:Reload the configuration file'
	'mode:List, activate, or deactivate modes'
	'help:Show help message and quit'
)

if (( CURRENT == 2 )); then
	_describe 'makoctl command' makoctl_cmds
else
	shift words
	(( CURRENT-- ))
	opt="${words[1]}"

	if (( CURRENT == 2 )); then
		case "${opt}" in
			dismiss)
				_arguments -s \
						   '(-a --all)'{-a,--all}'[Dismiss all notifications]' \
						   '(-g --group)'{-g,--group}'[Dismiss all the notifications in the last notification'\''s group]' \
						   '(-h --no-history)'{-h,--no-history}'[Dismiss without adding to history]' \
						   '-n[Dismiss the notification with the given id]:id:'
				;;
			invoke)
				_arguments -s \
						   '-n[Invoke an action on the notification with the given id]:id:' \
						   '*:action:'
				;;
			menu)
				_arguments -s \
						   '-n[Use a program to select one action on the notification with the given id]:id:' \
						   '*:prog and args:_command_names -e'
				;;
			mode)
				_arguments -s \
						   '*-a[Add mode]:mode:' \
						   '*-r[Remove mode]:mode:' \
						   '*-t[Toggle mode]:mode:' \
						   '*-s[Set mode]:mode:'
				;;
		esac
	fi
fi
