mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
37ef9bb465
dd94cc46e4377b14515be24894fd1cb42e233151 contrib: remove accounts from bash completion (fanquake) Pull request description: Also removes `setgenerate`. ACKs for top commit: jonasschnelli: utACK dd94cc46e4377b14515be24894fd1cb42e233151 Tree-SHA512: 218aa06841f4a347bb083c7f408c07fe80df7a30f7ce7a1126ec95971a9b66aff7c3c049d269da2c15f629bbde80e8c303bf6562bd5c1a36a6f6fd61ce9133e2
142 lines
4.1 KiB
Bash
142 lines
4.1 KiB
Bash
# 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[@]}" "$@"
|
|
}
|
|
|
|
_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
|
|
;;
|
|
signrawtransactionwithkey|signrawtransactionwithwallet)
|
|
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)
|
|
return 0
|
|
;;
|
|
getbalance|gettxout|importaddress|importpubkey|importprivkey|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|listreceivedbyaddress|sendrawtransaction)
|
|
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
case "$prev" in
|
|
backupwallet|dumpwallet|importwallet)
|
|
_filedir
|
|
return 0
|
|
;;
|
|
getaddednodeinfo|getrawmempool|lockunspent)
|
|
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
|
return 0
|
|
;;
|
|
getbalance|getnewaddress|listtransactions|sendmany)
|
|
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
|