#compdef store-cli

autoload -U is-at-least

_store-cli() {
    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[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
":: :_store-cli_commands" \
"*::: :->store-cli" \
&& ret=0
    case $state in
    (store-cli)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:store-cli-command-$line[1]:"
        case $line[1] in
            (use)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
':table -- Database table to connect:' \
&& ret=0
;;
(tables)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
&& ret=0
;;
(count)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
':table -- Database table to store file in:' \
&& ret=0
;;
(store)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
':table -- Database table to store file in:' \
'::file -- File to put into database. If no file is given, data are read from STDIN:' \
&& ret=0
;;
(retrieve)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
':table -- Database table to request file:' \
':chunk-id -- Information (file chunk) identifier returned before with the `store` command:' \
'::output -- File for output. The data are printed to stdout if no file is given:' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'-c+[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'--connect=[ZMQ socket for connecting daemon RPC interface]:CONNECT: ' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_store-cli_commands] )) ||
_store-cli_commands() {
    local commands; commands=(
'use:Use a database table' \
'tables:List used database tables' \
'count:Count number of stored items' \
'store:Stores file into database' \
'retrieve:Retrieves file from the database and outputs it into the provided file name, or onto stdout if no output file is specified' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'store-cli commands' commands "$@"
}
(( $+functions[_store-cli__count_commands] )) ||
_store-cli__count_commands() {
    local commands; commands=()
    _describe -t commands 'store-cli count commands' commands "$@"
}
(( $+functions[_store-cli__help_commands] )) ||
_store-cli__help_commands() {
    local commands; commands=()
    _describe -t commands 'store-cli help commands' commands "$@"
}
(( $+functions[_store-cli__retrieve_commands] )) ||
_store-cli__retrieve_commands() {
    local commands; commands=()
    _describe -t commands 'store-cli retrieve commands' commands "$@"
}
(( $+functions[_store-cli__store_commands] )) ||
_store-cli__store_commands() {
    local commands; commands=()
    _describe -t commands 'store-cli store commands' commands "$@"
}
(( $+functions[_store-cli__tables_commands] )) ||
_store-cli__tables_commands() {
    local commands; commands=()
    _describe -t commands 'store-cli tables commands' commands "$@"
}
(( $+functions[_store-cli__use_commands] )) ||
_store-cli__use_commands() {
    local commands; commands=()
    _describe -t commands 'store-cli use commands' commands "$@"
}

_store-cli "$@"
