#compdef install

autoload -U is-at-least

_install() {
    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[@]}" : \
'--backup=[make a backup of each existing destination file]' \
'-g+[install-help-group]:GROUP:_default' \
'--group=[install-help-group]:GROUP:_default' \
'-m+[install-help-mode]:MODE:_default' \
'--mode=[install-help-mode]:MODE:_default' \
'-o+[install-help-owner]:OWNER:_users' \
'--owner=[install-help-owner]:OWNER:_users' \
'--strip-program=[install-help-strip-program]:PROGRAM:_command_names -e' \
'-S+[override the usual backup suffix]:SUFFIX:_default' \
'--suffix=[override the usual backup suffix]:SUFFIX:_default' \
'-t+[install-help-target-directory]:DIRECTORY:_files -/' \
'--target-directory=[install-help-target-directory]:DIRECTORY:_files -/' \
'-Z+[install-help-context]' \
'--context=[install-help-context]' \
'-b[like --backup but does not accept an argument]' \
'-c[install-help-ignored]' \
'-C[install-help-compare]' \
'--compare[install-help-compare]' \
'-d[install-help-directory]' \
'--directory[install-help-directory]' \
'-D[install-help-create-leading]' \
'-p[install-help-preserve-timestamps]' \
'--preserve-timestamps[install-help-preserve-timestamps]' \
'-s[install-help-strip]' \
'--strip[install-help-strip]' \
'-T[install-help-no-target-directory]' \
'--no-target-directory[install-help-no-target-directory]' \
'-v[install-help-verbose]' \
'--verbose[install-help-verbose]' \
'-P[install-help-preserve-context]' \
'--preserve-context[install-help-preserve-context]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_install" ]; then
    _install "$@"
else
    compdef _install install
fi
