update bash-completion for v0.9

Recognize completable arguments of new and expanded commands.
Now that bitcoin-cli(1) exists, add completion for it as well.

Rebased-From: 16bfd68
This commit is contained in:
Christian von Roques 2014-03-04 12:24:59 -04:00 committed by Wladimir J. van der Laan
parent 12858f5234
commit 1ff620e975

View file

@ -1,5 +1,5 @@
# bash programmable completion for bitcoind(1) # bash programmable completion for bitcoind(1) and bitcoin-cli(1)
# Copyright (c) 2012 Christian von Roques <roques@mti.ag> # Copyright (c) 2012,2014 Christian von Roques <roques@mti.ag>
# Distributed under the MIT/X11 software license, see the accompanying # Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php. # file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -37,9 +37,35 @@ _bitcoind() {
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref -n = cur prev words cword _get_comp_words_by_ref -n = cur prev words cword
if ((cword > 4)); then
case ${words[cword-4]} in
signrawtransaction)
COMPREPLY=( $( compgen -W "ALL NONE SINGLE ALL|ANYONECANPAY NONE|ANYONECANPAY SINGLE|ANYONECANPAY" -- "$cur" ) )
return 0
;;
esac
fi
if ((cword > 3)); then
case ${words[cword-3]} in
addmultisigaddress)
_bitcoin_accounts
return 0
;;
gettxout|importprivkey)
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
return 0
;;
esac
fi
if ((cword > 2)); then if ((cword > 2)); then
case ${words[cword-2]} in case ${words[cword-2]} in
listreceivedbyaccount|listreceivedbyaddress) addnode)
COMPREPLY=( $( compgen -W "add remove onetry" -- "$cur" ) )
return 0
;;
getblock|getrawtransaction|listreceivedbyaccount|listreceivedbyaddress|sendrawtransaction)
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) ) COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
return 0 return 0
;; ;;
@ -51,11 +77,11 @@ _bitcoind() {
fi fi
case "$prev" in case "$prev" in
backupwallet) backupwallet|dumpwallet|importwallet)
_filedir _filedir
return 0 return 0
;; ;;
setgenerate) getmempool|lockunspent|setgenerate)
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) ) COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
return 0 return 0
;; ;;
@ -66,7 +92,7 @@ _bitcoind() {
esac esac
case "$cur" in case "$cur" in
-conf=*|-pid=*|-rpcsslcertificatechainfile=*|-rpcsslprivatekeyfile=*) -conf=*|-pid=*|-loadblock=*|-wallet=*|-rpcsslcertificatechainfile=*|-rpcsslprivatekeyfile=*)
cur="${cur#*=}" cur="${cur#*=}"
_filedir _filedir
return 0 return 0
@ -103,7 +129,7 @@ _bitcoind() {
esac esac
} }
complete -F _bitcoind bitcoind complete -F _bitcoind bitcoind bitcoin-cli
} }
# Local variables: # Local variables: