mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
Merge #8289: bash-completion: Adapt for 0.12 and 0.13
1ba3db6
bash-completion: Adapt for 0.12 and 0.13 (Christian von Roques)
This commit is contained in:
parent
1670472976
commit
26540aa5d1
154
contrib/dash-cli.bash-completion
Normal file
154
contrib/dash-cli.bash-completion
Normal file
@ -0,0 +1,154 @@
|
||||
# bash programmable completion for dash-cli(1)
|
||||
# Copyright (c) 2012-2016 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
# call $dash-cli for RPC
|
||||
_dash_rpc() {
|
||||
# determine already specified args necessary for RPC
|
||||
local rpcargs=()
|
||||
for i in ${COMP_LINE}; do
|
||||
case "$i" in
|
||||
-conf=*|-datadir=*|-regtest|-rpc*|-testnet)
|
||||
rpcargs=( "${rpcargs[@]}" "$i" )
|
||||
;;
|
||||
esac
|
||||
done
|
||||
$dash_cli "${rpcargs[@]}" "$@"
|
||||
}
|
||||
|
||||
# Add wallet accounts to COMPREPLY
|
||||
_dash_accounts() {
|
||||
local accounts
|
||||
accounts=$(_dash_rpc listaccounts | awk -F '"' '{ print $2 }')
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$accounts" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_dash_cli() {
|
||||
local cur prev words=() cword
|
||||
local dash_cli
|
||||
|
||||
# save and use original argument to invoke dash-cli for -help, help and RPC
|
||||
# as dash-cli might not be in $PATH
|
||||
dash_cli="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n = cur prev words cword
|
||||
|
||||
if ((cword > 5)); then
|
||||
case ${words[cword-5]} in
|
||||
sendtoaddress)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ((cword > 4)); then
|
||||
case ${words[cword-4]} in
|
||||
importaddress|listtransactions|setban)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
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)
|
||||
_dash_accounts
|
||||
return 0
|
||||
;;
|
||||
getbalance|gettxout|importaddress|importpubkey|importprivkey|listreceivedbyaccount|listreceivedbyaddress|listsinceblock)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ((cword > 2)); then
|
||||
case ${words[cword-2]} in
|
||||
addnode)
|
||||
COMPREPLY=( $( compgen -W "add remove onetry" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
setban)
|
||||
COMPREPLY=( $( compgen -W "add remove" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
fundrawtransaction|getblock|getblockheader|getmempoolancestors|getmempooldescendants|getrawtransaction|gettransaction|listaccounts|listreceivedbyaccount|listreceivedbyaddress|sendrawtransaction)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
move|setaccount)
|
||||
_dash_accounts
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$prev" in
|
||||
backupwallet|dumpwallet|importwallet)
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
getaddednodeinfo|getrawmempool|lockunspent|setgenerate)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
getaccountaddress|getaddressesbyaccount|getbalance|getnewaddress|getreceivedbyaccount|listtransactions|move|sendfrom|sendmany)
|
||||
_dash_accounts
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-conf=*)
|
||||
cur="${cur#*=}"
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
-datadir=*)
|
||||
cur="${cur#*=}"
|
||||
_filedir -d
|
||||
return 0
|
||||
;;
|
||||
-*=*) # prevent nonsense completions
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
local helpopts commands
|
||||
|
||||
# only parse -help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
||||
helpopts=$($dash_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
fi
|
||||
|
||||
# only parse help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
|
||||
commands=$(_dash_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
|
||||
|
||||
# Prevent space if an argument is desired
|
||||
if [[ $COMPREPLY == *= ]]; then
|
||||
compopt -o nospace
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
} &&
|
||||
complete -F _dash_cli dash-cli
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
||||
# sh-basic-offset: 4
|
||||
# sh-indent-comment: t
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
57
contrib/dash-tx.bash-completion
Normal file
57
contrib/dash-tx.bash-completion
Normal file
@ -0,0 +1,57 @@
|
||||
# bash programmable completion for dash-tx(1)
|
||||
# Copyright (c) 2016 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
_dash_tx() {
|
||||
local cur prev words=() cword
|
||||
local dash_tx
|
||||
|
||||
# save and use original argument to invoke dash-tx for -help
|
||||
# it might not be in $PATH
|
||||
dash_tx="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n =: cur prev words cword
|
||||
|
||||
case "$cur" in
|
||||
load=*:*)
|
||||
cur="${cur#load=*:}"
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
*=*) # prevent attempts to complete other arguments
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$cword" == 1 || ( "$prev" != "-create" && "$prev" == -* ) ]]; then
|
||||
# only options (or an uncompletable hex-string) allowed
|
||||
# parse dash-tx -help for options
|
||||
local helpopts
|
||||
helpopts=$($dash_tx -help | sed -e '/^ -/ p' -e d )
|
||||
COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
|
||||
else
|
||||
# only commands are allowed
|
||||
# parse -help for commands
|
||||
local helpcmds
|
||||
helpcmds=$($dash_tx -help | sed -e '1,/Commands:/d' -e 's/=.*/=/' -e '/^ [a-z]/ p' -e d )
|
||||
COMPREPLY=( $( compgen -W "$helpcmds" -- "$cur" ) )
|
||||
fi
|
||||
|
||||
# Prevent space if an argument is desired
|
||||
if [[ $COMPREPLY == *= ]]; then
|
||||
compopt -o nospace
|
||||
fi
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _dash_tx dash-tx
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
||||
# sh-basic-offset: 4
|
||||
# sh-indent-comment: t
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
@ -1,102 +1,21 @@
|
||||
# bash programmable completion for dashd(1) and dash-cli(1)
|
||||
# Copyright (c) 2012,2014 Christian von Roques <roques@mti.ag>
|
||||
# bash programmable completion for dashd(1) and dash-qt(1)
|
||||
# Copyright (c) 2012-2016 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
have dashd && {
|
||||
|
||||
# call $dashd for RPC
|
||||
_dash_rpc() {
|
||||
# determine already specified args necessary for RPC
|
||||
local rpcargs=()
|
||||
for i in ${COMP_LINE}; do
|
||||
case "$i" in
|
||||
-conf=*|-proxy*|-rpc*)
|
||||
rpcargs=( "${rpcargs[@]}" "$i" )
|
||||
;;
|
||||
esac
|
||||
done
|
||||
$dashd "${rpcargs[@]}" "$@"
|
||||
}
|
||||
|
||||
# Add dash accounts to COMPREPLY
|
||||
_dash_accounts() {
|
||||
local accounts
|
||||
accounts=$(_dash_rpc listaccounts | awk '/".*"/ { a=$1; gsub(/"/, "", a); print a}')
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$accounts" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_dashd() {
|
||||
local cur prev words=() cword
|
||||
local dashd
|
||||
|
||||
# save and use original argument to invoke dashd
|
||||
# dashd might not be in $PATH
|
||||
# save and use original argument to invoke dashd for -help
|
||||
# it might not be in $PATH
|
||||
dashd="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n = cur prev words cword
|
||||
|
||||
if ((cword > 4)); then
|
||||
case ${words[cword-4]} in
|
||||
listtransactions)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
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)
|
||||
_dash_accounts
|
||||
return 0
|
||||
;;
|
||||
getbalance|gettxout|importaddress|importprivkey|listreceivedbyaccount|listreceivedbyaddress|listsinceblock)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ((cword > 2)); then
|
||||
case ${words[cword-2]} in
|
||||
addnode)
|
||||
COMPREPLY=( $( compgen -W "add remove onetry" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
getblock|getrawtransaction|gettransaction|listaccounts|listreceivedbyaccount|listreceivedbyaddress|sendrawtransaction)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
move|setaccount)
|
||||
_dash_accounts
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$prev" in
|
||||
backupwallet|dumpwallet|importwallet)
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
getmempool|lockunspent|setgenerate)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
getaccountaddress|getaddressesbyaccount|getbalance|getnewaddress|getreceivedbyaccount|listtransactions|move|sendfrom|sendmany)
|
||||
_dash_accounts
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-conf=*|-pid=*|-loadblock=*|-wallet=*)
|
||||
-conf=*|-pid=*|-loadblock=*|-rootcertificates=*|-rpccookiefile=*|-wallet=*)
|
||||
cur="${cur#*=}"
|
||||
_filedir
|
||||
return 0
|
||||
@ -110,20 +29,14 @@ _dashd() {
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
local helpopts commands
|
||||
|
||||
# only parse --help if senseful
|
||||
# only parse -help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
||||
helpopts=$($dashd --help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
local helpopts
|
||||
helpopts=$($dashd -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
|
||||
fi
|
||||
|
||||
# only parse help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
|
||||
commands=$(_dash_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
|
||||
|
||||
# Prevent space if an argument is desired
|
||||
if [[ $COMPREPLY == *= ]]; then
|
||||
compopt -o nospace
|
||||
@ -131,10 +44,8 @@ _dashd() {
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _dashd dashd dash-cli
|
||||
}
|
||||
} &&
|
||||
complete -F _dashd dashd dash-qt
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
||||
|
1
contrib/debian/dash-tx.bash-completion
Normal file
1
contrib/debian/dash-tx.bash-completion
Normal file
@ -0,0 +1 @@
|
||||
contrib/dash-tx.bash-completion dash-tx
|
@ -1 +1,2 @@
|
||||
contrib/dashd.bash-completion dashd
|
||||
contrib/dash-cli.bash-completion dash-cli
|
Loading…
Reference in New Issue
Block a user