_uu-cp() {
    local i cur prev opts cmds
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    cmd=""
    opts=""

    for i in ${COMP_WORDS[@]}
    do
        case "${i}" in
            "$1")
                cmd="uu__cp"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        uu__cp)
            opts="-h -V -t -T -i -l -n -r -R -v -s -f -b -S -u -p -P -L -a -d -x -H --help --version --target-directory --no-target-directory --interactive --link --no-clobber --recursive --strip-trailing-slashes --verbose --symbolic-link --force --remove-destination --backup --suffix --update --reflink --attributes-only --preserve --preserve-default-attributes --no-preserve --parents --no-dereference --dereference --archive --one-file-system --copy-contents --sparse --context <paths>..."
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --target-directory)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -t)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --backup)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --suffix)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -S)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --reflink)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --preserve)
                    COMPREPLY=($(compgen -W "mode ownership timestamps links xattr all" -- "${cur}"))
                    return 0
                    ;;
                --no-preserve)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --sparse)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --context)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

complete -F _uu-cp -o bashdefault -o default uu-cp
