#compdef mcup

autoload -U is-at-least

_mcup() {
    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[@]}" \
'-g+[Selects artifacts based on the group ID. Subgroups are included by default.]:GROUPS: ' \
'--groups=[Selects artifacts based on the group ID. Subgroups are included by default.]:GROUPS: ' \
'-a+[Selects artifacts based on the artifact ID. Supports globbing like in '\''maven-*-plugin'\''.]:ARTIFACTS: ' \
'--artifacts=[Selects artifacts based on the artifact ID. Supports globbing like in '\''maven-*-plugin'\''.]:ARTIFACTS: ' \
'-v+[Selects artifacts based on version (ranges). Use '\''<n>..'\'' to select the n most recent versions, '\''..<n>'\'' to select the n oldest versions and '\''<version>'\'' to select one specific version only.]:VERSIONS: ' \
'--versions=[Selects artifacts based on version (ranges). Use '\''<n>..'\'' to select the n most recent versions, '\''..<n>'\'' to select the n oldest versions and '\''<version>'\'' to select one specific version only.]:VERSIONS: ' \
'-l+[Sets the location of the local maven repository. Respects the directory configured in '\''~/.m2/settings.xml'\''. Falls back to '\''~/.m2/repository'\'', if nothing has been specified or configured.]:LOCAL_REPOSITORY: ' \
'--local-repository=[Sets the location of the local maven repository. Respects the directory configured in '\''~/.m2/settings.xml'\''. Falls back to '\''~/.m2/repository'\'', if nothing has been specified or configured.]:LOCAL_REPOSITORY: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'(-s --snapshots)-r[Selects released artifacts only]' \
'(-s --snapshots)--releases[Selects released artifacts only]' \
'(-r --releases)-s[Selects snapshot artifacts only]' \
'(-r --releases)--snapshots[Selects snapshot artifacts only]' \
":: :_mcup_commands" \
"*::: :->mcup" \
&& ret=0
    case $state in
    (mcup)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:mcup-command-$line[1]:"
        case $line[1] in
            (keep)
_arguments "${_arguments_options[@]}" \
'-d[Does not remove artifacts]' \
'--dry-run[Does not remove artifacts]' \
'--list[Prints the full path to the artifacts that will be removed]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
&& ret=0
;;
(rm)
_arguments "${_arguments_options[@]}" \
'-d[Does not remove artifacts]' \
'--dry-run[Does not remove artifacts]' \
'--list[Prints the full path to the artifacts that will be removed]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
&& ret=0
;;
(du)
_arguments "${_arguments_options[@]}" \
'-o+[Defines whether (g)roups, (a)rtifacts and (v)ersions are included in the usage summary]:OUTPUT: ' \
'--output=[Defines whether (g)roups, (a)rtifacts and (v)ersions are included in the usage summary]:OUTPUT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_mcup_commands] )) ||
_mcup_commands() {
    local commands; commands=(
'keep:Keeps the artifacts matched by the filters and removes the rest' \
'rm:Removes the artifacts matched by the filters and keeps the rest' \
'du:Analyzes the size of the artifacts selected by the filters' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'mcup commands' commands "$@"
}
(( $+functions[_mcup__du_commands] )) ||
_mcup__du_commands() {
    local commands; commands=()
    _describe -t commands 'mcup du commands' commands "$@"
}
(( $+functions[_mcup__help_commands] )) ||
_mcup__help_commands() {
    local commands; commands=()
    _describe -t commands 'mcup help commands' commands "$@"
}
(( $+functions[_mcup__keep_commands] )) ||
_mcup__keep_commands() {
    local commands; commands=()
    _describe -t commands 'mcup keep commands' commands "$@"
}
(( $+functions[_mcup__rm_commands] )) ||
_mcup__rm_commands() {
    local commands; commands=()
    _describe -t commands 'mcup rm commands' commands "$@"
}

_mcup "$@"