#compdef oniri

autoload -U is-at-least

_oniri() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-H+[Set the height size tolerance (in pixels) when comparing the window size to the output size to determine if the window is maximized or not]:NUMBER:_default' \
'--height-tolerance=[Set the height size tolerance (in pixels) when comparing the window size to the output size to determine if the window is maximized or not]:NUMBER:_default' \
'-W+[Set the width size tolerance (in pixels) when comparing the window size to the output size to determine if the window is maximized or not]:NUMBER:_default' \
'--width-tolerance=[Set the width size tolerance (in pixels) when comparing the window size to the output size to determine if the window is maximized or not]:NUMBER:_default' \
'-F[Only maximize the first opened window, do not act on the last remaining one]' \
'--first-only[Only maximize the first opened window, do not act on the last remaining one]' \
'-T[Unmaximize the first window when opening a second one, like in a tiling compositor]' \
'--tiling-layout[Unmaximize the first window when opening a second one, like in a tiling compositor]' \
'-E[Maximize windows to edges]' \
'--edges-maximizing[Maximize windows to edges]' \
'-R[Reclaim empty screen space left by closed windows]' \
'--reclaim-space[Reclaim empty screen space left by closed windows]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_oniri_commands" \
"*::: :->oniri" \
&& ret=0
    case $state in
    (oniri)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:oniri-command-$line[1]:"
        case $line[1] in
            (completion)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(manual)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_oniri__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:oniri-help-command-$line[1]:"
        case $line[1] in
            (completion)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(manual)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_oniri_commands] )) ||
_oniri_commands() {
    local commands; commands=(
'completion:Generate shell completion for the specified shell' \
'manual:Generate the man page' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'oniri commands' commands "$@"
}
(( $+functions[_oniri__subcmd__completion_commands] )) ||
_oniri__subcmd__completion_commands() {
    local commands; commands=()
    _describe -t commands 'oniri completion commands' commands "$@"
}
(( $+functions[_oniri__subcmd__help_commands] )) ||
_oniri__subcmd__help_commands() {
    local commands; commands=(
'completion:Generate shell completion for the specified shell' \
'manual:Generate the man page' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'oniri help commands' commands "$@"
}
(( $+functions[_oniri__subcmd__help__subcmd__completion_commands] )) ||
_oniri__subcmd__help__subcmd__completion_commands() {
    local commands; commands=()
    _describe -t commands 'oniri help completion commands' commands "$@"
}
(( $+functions[_oniri__subcmd__help__subcmd__help_commands] )) ||
_oniri__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'oniri help help commands' commands "$@"
}
(( $+functions[_oniri__subcmd__help__subcmd__manual_commands] )) ||
_oniri__subcmd__help__subcmd__manual_commands() {
    local commands; commands=()
    _describe -t commands 'oniri help manual commands' commands "$@"
}
(( $+functions[_oniri__subcmd__manual_commands] )) ||
_oniri__subcmd__manual_commands() {
    local commands; commands=()
    _describe -t commands 'oniri manual commands' commands "$@"
}

if [ "$funcstack[1]" = "_oniri" ]; then
    _oniri "$@"
else
    compdef _oniri oniri
fi
