#compdef ln

autoload -U is-at-least

_ln() {
    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]' \
'-S+[override the usual backup suffix]:SUFFIX:_default' \
'--suffix=[override the usual backup suffix]:SUFFIX:_default' \
'(-T --no-target-directory)-t+[ln-help-target-directory]:DIRECTORY:_files -/' \
'(-T --no-target-directory)--target-directory=[ln-help-target-directory]:DIRECTORY:_files -/' \
'-b[like --backup but does not accept an argument]' \
'-f[ln-help-force]' \
'--force[ln-help-force]' \
'-i[ln-help-interactive]' \
'--interactive[ln-help-interactive]' \
'-n[ln-help-no-dereference]' \
'--no-dereference[ln-help-no-dereference]' \
'-L[ln-help-logical]' \
'--logical[ln-help-logical]' \
'-P[ln-help-physical]' \
'--physical[ln-help-physical]' \
'-s[ln-help-symbolic]' \
'--symbolic[ln-help-symbolic]' \
'-T[ln-help-no-target-directory]' \
'--no-target-directory[ln-help-no-target-directory]' \
'-r[ln-help-relative]' \
'--relative[ln-help-relative]' \
'-v[ln-help-verbose]' \
'--verbose[ln-help-verbose]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
}

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

if [ "$funcstack[1]" = "_ln" ]; then
    _ln "$@"
else
    compdef _ln ln
fi
