#compdef lnpd

autoload -U is-at-least

_lnpd() {
    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[@]}" \
'-k+[Node key file]:KEY_FILE:_files' \
'--key-file=[Node key file]:KEY_FILE:_files' \
'-d+[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]:DATA_DIR:_files -/' \
'--data-dir=[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]: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' \
'--msg=[ZMQ socket for internal message bus]:MSG_SOCKET:_files' \
'--ctl=[ZMQ socket for internal service bus]:CTL_SOCKET:_files' \
'-r+[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'--rpc=[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'-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: ' \
'-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' \
'-p+[Customize port used by lightning peer network]:PORT: ' \
'--port=[Customize port used by lightning peer network]:PORT: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
'--threaded-daemons[Spawn daemons as threads and not processes]' \
":: :_lnpd_commands" \
"*::: :->lnpd" \
&& ret=0
    case $state in
    (lnpd)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:lnpd-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" \
'-d+[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]:DATA_DIR:_files -/' \
'--data-dir=[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]: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' \
'--msg=[ZMQ socket for internal message bus]:MSG_SOCKET:_files' \
'--ctl=[ZMQ socket for internal service bus]:CTL_SOCKET:_files' \
'-r+[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'--rpc=[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'-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[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'-d+[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]:DATA_DIR:_files -/' \
'--data-dir=[<\[_\]<\[_\]>::into_vec(box \[$($x),+\]).into_iter().flatten() are located]: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' \
'--msg=[ZMQ socket for internal message bus]:MSG_SOCKET:_files' \
'--ctl=[ZMQ socket for internal service bus]:CTL_SOCKET:_files' \
'-r+[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'--rpc=[ZMQ socket for connecting daemon RPC interface]:RPC_SOCKET: ' \
'-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: ' \
'*-v[Set verbosity level]' \
'*--verbose[Set verbosity level]' \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_lnpd_commands] )) ||
_lnpd_commands() {
    local commands; commands=(
'init:Initialize data directory' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'lnpd commands' commands "$@"
}
(( $+functions[_lnpd__help_commands] )) ||
_lnpd__help_commands() {
    local commands; commands=()
    _describe -t commands 'lnpd help commands' commands "$@"
}
(( $+functions[_lnpd__init_commands] )) ||
_lnpd__init_commands() {
    local commands; commands=()
    _describe -t commands 'lnpd init commands' commands "$@"
}

_lnpd "$@"
