#compdef peerd

autoload -U is-at-least

_peerd() {
    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[@]}" \
'-L+[Start daemon in listening mode binding the provided local address]:LISTEN:_hosts' \
'--listen=[Start daemon in listening mode binding the provided local address]:LISTEN:_hosts' \
'-C+[Connect to a remote peer with the provided address after start]:CONNECT: ' \
'--connect=[Connect to a remote peer with the provided address after start]:CONNECT: ' \
'-p+[Customize port used by lightning peer network]:PORT: ' \
'--port=[Customize port used by lightning peer network]:PORT: ' \
'-k+[Node key file]:KEY_FILE:_files' \
'--key-file=[Node key file]:KEY_FILE:_files' \
'-d+[Data directory path]:DATA_DIR:_files -/' \
'--data-dir=[Data directory path]:DATA_DIR:_files -/' \
'-c+[Path for the configuration file]:CONFIG:_files' \
'--config=[Path for the configuration file]:CONFIG:_files' \
'-T+[Use Tor]:TOR_PROXY:_hosts' \
'--tor-proxy=[Use Tor]:TOR_PROXY:_hosts' \
'-M+[ZMQ socket for peer message bus used to communicate with LNP node peerd service]:MSG_ENDPOINT:_files' \
'--msg=[ZMQ socket for peer message bus used to communicate with LNP node peerd service]:MSG_ENDPOINT:_files' \
'-X+[ZMQ socket for internal service control bus]:CTL_ENDPOINT:_files' \
'--ctl=[ZMQ socket for internal service control bus]:CTL_ENDPOINT:_files' \
'-R+[ZMQ socket for LNP Node client-server RPC API]:RPC_ENDPOINT: ' \
'--rpc=[ZMQ socket for LNP Node client-server RPC API]:RPC_ENDPOINT: ' \
'-n+[Blockchain to use]:CHAIN: ' \
'--chain=[Blockchain to use]:CHAIN: ' \
'--electrum-server=[Electrum server to use]:ELECTRUM_SERVER:_hosts' \
'--electrum-port=[Customize Electrum server port number. By default the wallet will use port matching the selected network]:ELECTRUM_PORT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'(--bifrost)--bolt[Use BOLT lightning network protocol]' \
'--bifrost[Use Bifrost lightning network protocol]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
'-t[Spawn daemons as threads and not processes]' \
'--threaded[Spawn daemons as threads and not processes]' \
&& ret=0
}

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

_peerd "$@"
