#compdef trashy

autoload -U is-at-least

_trashy() {
    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[@]}" \
'-c+[When to use colors]:COLOR_STATUS:(auto always never)' \
'--color=[When to use colors]:COLOR_STATUS:(auto always never)' \
'--time=[When to use time]:TIME_DISPLAY_MODE:(precise imprecise)' \
'-t+[When to format as a table]:TABLE_STATUS:(auto always never)' \
'--table=[When to format as a table]:TABLE_STATUS:(auto always never)' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_trashy_commands" \
"*::: :->trashy" \
&& ret=0
    case $state in
    (trashy)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:trashy-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" \
'*--before=[Filter by time (older than)]:BEFORE: ' \
'*--older-than=[Filter by time (older than)]:BEFORE: ' \
'*--older=[Filter by time (older than)]:BEFORE: ' \
'*--within=[Filter by time]:WITHIN: ' \
'*--newer-than=[Filter by time]:WITHIN: ' \
'*--newer=[Filter by time]:WITHIN: ' \
'*--regex=[Filter by regex]:REGEX: ' \
'*--glob=[Filter by glob]:GLOB: ' \
'*--substring=[Filter by substring]:SUBSTRING: ' \
'*--exact=[Filter by exact match]:EXACT: ' \
'-m+[What type of pattern to use]:MATCH:(regex substring glob exact)' \
'--match=[What type of pattern to use]:MATCH:(regex substring glob exact)' \
'*-d+[Filter by directory]:DIRECTORIES:_files' \
'*--directory=[Filter by directory]:DIRECTORIES:_files' \
'*--dir=[Filter by directory]:DIRECTORIES:_files' \
'-n+[Show '\''n'\'' maximum trash items]:MAX: ' \
'--max=[Show '\''n'\'' maximum trash items]:MAX: ' \
'--rev[Reverse the sorting of trash items]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::patterns -- Filter by pattern:' \
&& ret=0
;;
(put)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
'*::paths -- The paths to put into the trash:_files' \
&& ret=0
;;
(empty)
_arguments "${_arguments_options[@]}" \
'*--before=[Filter by time (older than)]:BEFORE: ' \
'*--older-than=[Filter by time (older than)]:BEFORE: ' \
'*--older=[Filter by time (older than)]:BEFORE: ' \
'*--within=[Filter by time]:WITHIN: ' \
'*--newer-than=[Filter by time]:WITHIN: ' \
'*--newer=[Filter by time]:WITHIN: ' \
'*--regex=[Filter by regex]:REGEX: ' \
'*--glob=[Filter by glob]:GLOB: ' \
'*--substring=[Filter by substring]:SUBSTRING: ' \
'*--exact=[Filter by exact match]:EXACT: ' \
'-m+[What type of pattern to use]:MATCH:(regex substring glob exact)' \
'--match=[What type of pattern to use]:MATCH:(regex substring glob exact)' \
'*-d+[Filter by directory]:DIRECTORIES:_files' \
'*--directory=[Filter by directory]:DIRECTORIES:_files' \
'*--dir=[Filter by directory]:DIRECTORIES:_files' \
'-n+[Show '\''n'\'' maximum trash items]:MAX: ' \
'--max=[Show '\''n'\'' maximum trash items]:MAX: ' \
'(--before --within --glob --regex --exact --substring -m --match --rev -n --max -d --directory)*-r+[Filter by ranges]:RANGES: ' \
'(--before --within --glob --regex --exact --substring -m --match --rev -n --max -d --directory)*--ranges=[Filter by ranges]:RANGES: ' \
'--rev[Reverse the sorting of trash items]' \
'(--before --within --glob --regex --exact --substring -m --match --rev -n --max -d --directory)--all[Empty all files]' \
'-f[Skip confirmation]' \
'--force[Skip confirmation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::patterns -- Filter by pattern:' \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" \
'*--before=[Filter by time (older than)]:BEFORE: ' \
'*--older-than=[Filter by time (older than)]:BEFORE: ' \
'*--older=[Filter by time (older than)]:BEFORE: ' \
'*--within=[Filter by time]:WITHIN: ' \
'*--newer-than=[Filter by time]:WITHIN: ' \
'*--newer=[Filter by time]:WITHIN: ' \
'*--regex=[Filter by regex]:REGEX: ' \
'*--glob=[Filter by glob]:GLOB: ' \
'*--substring=[Filter by substring]:SUBSTRING: ' \
'*--exact=[Filter by exact match]:EXACT: ' \
'-m+[What type of pattern to use]:MATCH:(regex substring glob exact)' \
'--match=[What type of pattern to use]:MATCH:(regex substring glob exact)' \
'*-d+[Filter by directory]:DIRECTORIES:_files' \
'*--directory=[Filter by directory]:DIRECTORIES:_files' \
'*--dir=[Filter by directory]:DIRECTORIES:_files' \
'-n+[Show '\''n'\'' maximum trash items]:MAX: ' \
'--max=[Show '\''n'\'' maximum trash items]:MAX: ' \
'(--before --within --glob --regex --exact --substring -m --match --rev -n --max -d --directory)*-r+[Filter by ranges]:RANGES: ' \
'(--before --within --glob --regex --exact --substring -m --match --rev -n --max -d --directory)*--ranges=[Filter by ranges]:RANGES: ' \
'--rev[Reverse the sorting of trash items]' \
'-f[Skip confirmation]' \
'--force[Skip confirmation]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::patterns -- Filter by pattern:' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
':shell -- shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(manpage)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_trashy__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:trashy-help-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(put)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(empty)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(manpage)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_trashy_commands] )) ||
_trashy_commands() {
    local commands; commands=(
'list:List files' \
'put:Put files' \
'empty:PERMANENTLY removes files' \
'restore:Restore files' \
'completions:Generates completion for a shell' \
'manpage:Generates manpages' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'trashy commands' commands "$@"
}
(( $+functions[_trashy__completions_commands] )) ||
_trashy__completions_commands() {
    local commands; commands=()
    _describe -t commands 'trashy completions commands' commands "$@"
}
(( $+functions[_trashy__help__completions_commands] )) ||
_trashy__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help completions commands' commands "$@"
}
(( $+functions[_trashy__empty_commands] )) ||
_trashy__empty_commands() {
    local commands; commands=()
    _describe -t commands 'trashy empty commands' commands "$@"
}
(( $+functions[_trashy__help__empty_commands] )) ||
_trashy__help__empty_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help empty commands' commands "$@"
}
(( $+functions[_trashy__help_commands] )) ||
_trashy__help_commands() {
    local commands; commands=(
'list:List files' \
'put:Put files' \
'empty:PERMANENTLY removes files' \
'restore:Restore files' \
'completions:Generates completion for a shell' \
'manpage:Generates manpages' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'trashy help commands' commands "$@"
}
(( $+functions[_trashy__help__help_commands] )) ||
_trashy__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help help commands' commands "$@"
}
(( $+functions[_trashy__help__list_commands] )) ||
_trashy__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help list commands' commands "$@"
}
(( $+functions[_trashy__list_commands] )) ||
_trashy__list_commands() {
    local commands; commands=()
    _describe -t commands 'trashy list commands' commands "$@"
}
(( $+functions[_trashy__help__manpage_commands] )) ||
_trashy__help__manpage_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help manpage commands' commands "$@"
}
(( $+functions[_trashy__manpage_commands] )) ||
_trashy__manpage_commands() {
    local commands; commands=()
    _describe -t commands 'trashy manpage commands' commands "$@"
}
(( $+functions[_trashy__help__put_commands] )) ||
_trashy__help__put_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help put commands' commands "$@"
}
(( $+functions[_trashy__put_commands] )) ||
_trashy__put_commands() {
    local commands; commands=()
    _describe -t commands 'trashy put commands' commands "$@"
}
(( $+functions[_trashy__help__restore_commands] )) ||
_trashy__help__restore_commands() {
    local commands; commands=()
    _describe -t commands 'trashy help restore commands' commands "$@"
}
(( $+functions[_trashy__restore_commands] )) ||
_trashy__restore_commands() {
    local commands; commands=()
    _describe -t commands 'trashy restore commands' commands "$@"
}

if [ "$funcstack[1]" = "_trashy" ]; then
    _trashy "$@"
else
    compdef _trashy trashy
fi
