#compdef gpaste

if (( CURRENT == 2 )); then

    local commands

    commands=(
        {add,a}:"Set text to clipboard"
        {backup-history,bh}:"Backup current history"
        {daemon-reexec,dr}:"Reexecute the daemon"
        {delete,d}:"Delete an element of the history"
        {delete-history,dh}:"Delete a history"
        {empty,e}:"Empty the history"
        {file,f}:"Put content of file into clipboard"
        {get,g}:"Display an element of the history"
        {help,--help,-h}:"Display the help"
        {history,h}:"Display the history with indexes"
        {list-histories,lh}:"List available histories"
        {raw-history,rh}:"Display the history without indexes"
        {select,set,s}:"Select an element of the history"
        {settings,s,preferences,p}:"Launch the configuration tool"
        {start,daemon,d}:"Start the daemon"
        {stop,quit,q}:"Shutdown the daemon"
        {switch-history,sh}:"Switch to another history"
        {version,v,--version,-v}:"Display the version"
        {zero-history,zh}:"Display the history with NUL as separator"
    )

    _describe -t commands command commands

else if  (( CURRENT == 3 ))

    case "${words[2]}" in
        "file"|"f")
            _arguments -s : '*: :_files'
    esac

fi
