#compdef tre

autoload -U is-at-least

_tre() {
    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+[Create aliases for each displayed result, and add a number in front of file name to indicate the alias name. For example, a number "42" means an shell alias "e42" has been created. Running "e42" will cause the associated file or directory to be open with $EDITOR (or a default program for the file type on Windows), or a command specified along with this command]:COMMAND: ' \
'--editor=[Create aliases for each displayed result, and add a number in front of file name to indicate the alias name. For example, a number "42" means an shell alias "e42" has been created. Running "e42" will cause the associated file or directory to be open with $EDITOR (or a default program for the file type on Windows), or a command specified along with this command]:COMMAND: ' \
'-l+[Limit depth of the tree in output]:LIMIT: ' \
'--limit=[Limit depth of the tree in output]:LIMIT: ' \
'*-E+[Exclude paths matching a regex pattern. Repeatable]:PATTERN: ' \
'*--exclude=[Exclude paths matching a regex pattern. Repeatable]:PATTERN: ' \
'-c+[When to color the output. `automatic` means when printing to a terminal, tre will include colors; otherwise it will disable colors]:WHEN:(automatic always never)' \
'--color=[When to color the output. `automatic` means when printing to a terminal, tre will include colors; otherwise it will disable colors]:WHEN:(automatic always never)' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-a[Print all files and directories, including hidden ones]' \
'--all[Print all files and directories, including hidden ones]' \
'-s[Use normal print despite gitignore settings. '\''-a'\'' has higher priority]' \
'--simple[Use normal print despite gitignore settings. '\''-a'\'' has higher priority]' \
'-d[Only list directories in output]' \
'--directories[Only list directories in output]' \
'-j[Output JSON instead of tree diagram]' \
'--json[Output JSON instead of tree diagram]' \
'-p[Generate portable (absolute) paths for editor aliases. By default, aliases use relative paths for better performance]' \
'--portable[Generate portable (absolute) paths for editor aliases. By default, aliases use relative paths for better performance]' \
'::path:' \
&& ret=0
}

(( $+functions[_tre_commands] )) ||
_tre_commands() {
    local commands; commands=()
    _describe -t commands 'tre commands' commands "$@"
}

_tre "$@"
