# Copyright (c) 2012-2024 The Limenka developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

# call $limenka-cli for RPC
_limenka_rpc() {
    # determine already specified args necessary for RPC
    local rpcargs=()
    for i in ${COMP_LINE}; do
        case "$i" in
            -conf=*|-datadir=*|-regtest|-rpc*|-testnet|-testnet4)
                rpcargs=( "${rpcargs[@]}" "$i" )
                ;;
        esac
    done
    $limenka_cli "${rpcargs[@]}" "$@"
}

_limenka_cli() {
    local cur prev words=() cword
    local limenka_cli

    # save and use original argument to invoke limenka-cli for -help, help and RPC
    # as limenka-cli might not be in $PATH
    limenka_cli="$1"

    COMPREPLY=()
    _get_comp_words_by_ref -n = cur prev words cword

