#compdef fnottctl

_arguments \
    -C \
    '1:cmd:->cmds' \
    ':id:->id'

case ${state} in
    (cmds)
        local -a commands
        commands=('dismiss:dismiss a notification'
                   'actions:show and apply actions for a notification'
                   'list:list IDs of all active notifications'
                   'quit:stop the fnott daemon')

        _arguments \
            -s \
            '(-v --version)'{-v,--version}'[show the version number and quit]' \
            '(-h --help)'{-h,--help}'[show help message and quit]'
        _describe 'command' commands
        ret=0
        ;;

    (id)
        case ${line[1]} in
            (actions|dismiss)
                local -a ids
                ids=("${(f)$(fnottctl list)}")

                if [[ "${line[1]}" == "dismiss" ]]; then
                    ids+=('all:all notifications')
                fi

                _describe 'notification' ids
                ret=0
                ;;
        esac
        ;;
esac

return 1
