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)
86 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
89 z_importkey|z_importviewingkey)
90 COMPREPLY=( $( compgen -W "yes no whenkeyisnew" -- "$cur" ) )
101 backupwallet|dumpwallet|importwallet|z_exportwallet|z_importwallet)
105 getaddednodeinfo|getrawmempool|lockunspent|setgenerate)
106 COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
109 getaccountaddress|getaddressesbyaccount|getbalance|getnewaddress|getreceivedbyaccount|listtransactions|move|sendfrom|sendmany)
126 -*=*) # prevent nonsense completions
130 local helpopts commands
132 # only parse -help if senseful
133 if [[ -z "$cur" || "$cur" =~ ^- ]]; then
134 helpopts=$($zcash_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
137 # only parse help if senseful
138 if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
139 commands=$(_zcash_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
142 COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
144 # Prevent space if an argument is desired
145 if [[ $COMPREPLY == *= ]]; then
152 complete -F _zcash_cli zcash-cli
157 # sh-indent-comment: t
158 # indent-tabs-mode: nil
160 # ex: ts=4 sw=4 et filetype=sh