1 # bash programmable completion for zcash-cli(1)
2 # Copyright (c) 2012-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 # call $zcash-cli for RPC
8 # determine already specified args necessary for RPC
10 for i in ${COMP_LINE}; do
12 -conf=*|-datadir=*|-regtest|-rpc*|-testnet)
13 rpcargs=( "${rpcargs[@]}" "$i" )
17 $zcash_cli "${rpcargs[@]}" "$@"
20 # Add wallet accounts to COMPREPLY
23 # Accounts are deprecated in Zcash
24 #accounts=$(_zcash_rpc listaccounts | awk -F '"' '{ print $2 }')
26 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$accounts" -- "$cur" ) )
30 local cur prev words=() cword
33 # save and use original argument to invoke zcash-cli for -help, help and RPC
34 # as zcash-cli might not be in $PATH
38 _get_comp_words_by_ref -n = cur prev words cword
40 if ((cword > 5)); then
41 case ${words[cword-5]} in
43 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
49 if ((cword > 4)); then
50 case ${words[cword-4]} in
51 importaddress|listtransactions|setban)
52 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
56 COMPREPLY=( $( compgen -W "ALL NONE SINGLE ALL|ANYONECANPAY NONE|ANYONECANPAY SINGLE|ANYONECANPAY" -- "$cur" ) )
62 if ((cword > 3)); then
63 case ${words[cword-3]} in
68 getbalance|gettxout|importaddress|importpubkey|importprivkey|listreceivedbyaccount|listreceivedbyaddress|listsinceblock)
69 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
75 if ((cword > 2)); then
76 case ${words[cword-2]} in
78 COMPREPLY=( $( compgen -W "add remove onetry" -- "$cur" ) )
82 COMPREPLY=( $( compgen -W "add remove" -- "$cur" ) )
85 fundrawtransaction|getblock|getblockheader|getmempoolancestors|getmempooldescendants|getrawtransaction|gettransaction|listaccounts|listreceivedbyaccount|listreceivedbyaddress|sendrawtransaction|z_importkey)
86 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
97 backupwallet|dumpwallet|importwallet|z_exportwallet|z_importwallet)
101 getaddednodeinfo|getrawmempool|lockunspent|setgenerate)
102 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
105 getaccountaddress|getaddressesbyaccount|getbalance|getnewaddress|getreceivedbyaccount|listtransactions|move|sendfrom|sendmany)
122 -*=*) # prevent nonsense completions
126 local helpopts commands
128 # only parse -help if senseful
129 if [[ -z "$cur" || "$cur" =~ ^- ]]; then
130 helpopts=$($zcash_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
133 # only parse help if senseful
134 if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
135 commands=$(_zcash_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
138 COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
140 # Prevent space if an argument is desired
141 if [[ $COMPREPLY == *= ]]; then
148 complete -F _zcash_cli zcash-cli
153 # sh-indent-comment: t
154 # indent-tabs-mode: nil
156 # ex: ts=4 sw=4 et filetype=sh