#compdef ranger

autoload -U is-at-least

_ranger() {
    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[@]}" \
'-e[Enables experimental features.]' \
'--experimental[Enables experimental features.]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_ranger_commands" \
"*::: :->ranger" \
&& ret=0
    case $state in
    (ranger)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ranger-command-$line[1]:"
        case $line[1] in
            (man)
_arguments "${_arguments_options[@]}" \
'-o+[]: : ' \
'--out=[]: : ' \
'-f+[]: :(manpages markdown)' \
'--format=[]: :(manpages markdown)' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(autocomplete)
_arguments "${_arguments_options[@]}" \
'-o+[]: : ' \
'--out=[]: : ' \
'-s+[]: :(bash zsh fish elvish powershell)' \
'--shell=[]: :(bash zsh fish elvish powershell)' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(generate)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_ranger__generate_commands" \
"*::: :->generate" \
&& ret=0

    case $state in
    (generate)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ranger-generate-command-$line[1]:"
        case $line[1] in
            (git)
_arguments "${_arguments_options[@]}" \
'-o+[]: : ' \
'--out=[]: : ' \
'-r+[]: : ' \
'--repo=[]: : ' \
'-b+[]: : ' \
'--branch=[]: : ' \
'-f+[]: : ' \
'--folder=[]: : ' \
'*-v+[A variable in the template (placeholder). This takes precendence over varfile.]: : ' \
'*--var=[A variable in the template (placeholder). This takes precendence over varfile.]: : ' \
'--varfile=[A file path containing variables in the template (placeholder).]: : ' \
'--force[]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(local)
_arguments "${_arguments_options[@]}" \
'-o+[]: : ' \
'--out=[]: : ' \
'-f+[]: : ' \
'--folder=[]: : ' \
'*-v+[A variable in the template (placeholder). This takes precendence over varfile.]: : ' \
'*--var=[A variable in the template (placeholder). This takes precendence over varfile.]: : ' \
'--varfile=[A file path containing variables in the template (placeholder).]: : ' \
'--force[]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_ranger__generate__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ranger-generate-help-command-$line[1]:"
        case $line[1] in
            (git)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(local)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_ranger__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ranger-help-command-$line[1]:"
        case $line[1] in
            (man)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(autocomplete)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(generate)
_arguments "${_arguments_options[@]}" \
":: :_ranger__help__generate_commands" \
"*::: :->generate" \
&& ret=0

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

(( $+functions[_ranger_commands] )) ||
_ranger_commands() {
    local commands; commands=(
'man:Renders the manual.' \
'autocomplete:Renders shell completion scripts.' \
'generate:Generate command.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ranger commands' commands "$@"
}
(( $+functions[_ranger__autocomplete_commands] )) ||
_ranger__autocomplete_commands() {
    local commands; commands=()
    _describe -t commands 'ranger autocomplete commands' commands "$@"
}
(( $+functions[_ranger__help__autocomplete_commands] )) ||
_ranger__help__autocomplete_commands() {
    local commands; commands=()
    _describe -t commands 'ranger help autocomplete commands' commands "$@"
}
(( $+functions[_ranger__generate_commands] )) ||
_ranger__generate_commands() {
    local commands; commands=(
'git:Generate from git repo.' \
'local:Generate from a local source folder.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ranger generate commands' commands "$@"
}
(( $+functions[_ranger__help__generate_commands] )) ||
_ranger__help__generate_commands() {
    local commands; commands=(
'git:Generate from git repo.' \
'local:Generate from a local source folder.' \
    )
    _describe -t commands 'ranger help generate commands' commands "$@"
}
(( $+functions[_ranger__generate__git_commands] )) ||
_ranger__generate__git_commands() {
    local commands; commands=()
    _describe -t commands 'ranger generate git commands' commands "$@"
}
(( $+functions[_ranger__generate__help__git_commands] )) ||
_ranger__generate__help__git_commands() {
    local commands; commands=()
    _describe -t commands 'ranger generate help git commands' commands "$@"
}
(( $+functions[_ranger__help__generate__git_commands] )) ||
_ranger__help__generate__git_commands() {
    local commands; commands=()
    _describe -t commands 'ranger help generate git commands' commands "$@"
}
(( $+functions[_ranger__generate__help_commands] )) ||
_ranger__generate__help_commands() {
    local commands; commands=(
'git:Generate from git repo.' \
'local:Generate from a local source folder.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ranger generate help commands' commands "$@"
}
(( $+functions[_ranger__generate__help__help_commands] )) ||
_ranger__generate__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ranger generate help help commands' commands "$@"
}
(( $+functions[_ranger__help_commands] )) ||
_ranger__help_commands() {
    local commands; commands=(
'man:Renders the manual.' \
'autocomplete:Renders shell completion scripts.' \
'generate:Generate command.' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ranger help commands' commands "$@"
}
(( $+functions[_ranger__help__help_commands] )) ||
_ranger__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ranger help help commands' commands "$@"
}
(( $+functions[_ranger__generate__help__local_commands] )) ||
_ranger__generate__help__local_commands() {
    local commands; commands=()
    _describe -t commands 'ranger generate help local commands' commands "$@"
}
(( $+functions[_ranger__generate__local_commands] )) ||
_ranger__generate__local_commands() {
    local commands; commands=()
    _describe -t commands 'ranger generate local commands' commands "$@"
}
(( $+functions[_ranger__help__generate__local_commands] )) ||
_ranger__help__generate__local_commands() {
    local commands; commands=()
    _describe -t commands 'ranger help generate local commands' commands "$@"
}
(( $+functions[_ranger__help__man_commands] )) ||
_ranger__help__man_commands() {
    local commands; commands=()
    _describe -t commands 'ranger help man commands' commands "$@"
}
(( $+functions[_ranger__man_commands] )) ||
_ranger__man_commands() {
    local commands; commands=()
    _describe -t commands 'ranger man commands' commands "$@"
}

if [ "$funcstack[1]" = "_ranger" ]; then
    _ranger "$@"
else
    compdef _ranger ranger
fi
