mirror of
https://git.hush.is/hush/hush3.git
synced 2025-09-24 00:04:19 -04:00
Port bash completion from ZEC 4d6498b900
This commit is contained in:
parent
076452eeaa
commit
1d7748b190
@ -1,10 +1,10 @@
|
||||
# bash programmable completion for bitcoin-cli(1)
|
||||
# bash programmable completion for komodo-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 $bitcoin-cli for RPC
|
||||
_zcash_rpc() {
|
||||
# call $komodo-cli for RPC
|
||||
_komodo_rpc() {
|
||||
# determine already specified args necessary for RPC
|
||||
local rpcargs=()
|
||||
for i in ${COMP_LINE}; do
|
||||
@ -14,25 +14,25 @@ _zcash_rpc() {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
$bitcoin_cli "${rpcargs[@]}" "$@"
|
||||
$komodo_cli "${rpcargs[@]}" "$@"
|
||||
}
|
||||
|
||||
# Add wallet accounts to COMPREPLY
|
||||
_zcash_accounts() {
|
||||
_komodo_accounts() {
|
||||
local accounts
|
||||
# Accounts are deprecated in Zcash
|
||||
#accounts=$(_zcash_rpc listaccounts | awk -F '"' '{ print $2 }')
|
||||
# Accounts are deprecated in komodo
|
||||
#accounts=$(_komodo_rpc listaccounts | awk -F '"' '{ print $2 }')
|
||||
accounts="\\\"\\\""
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$accounts" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_zcash_cli() {
|
||||
_komodo_cli() {
|
||||
local cur prev words=() cword
|
||||
local bitcoin_cli
|
||||
local komodo_cli
|
||||
|
||||
# save and use original argument to invoke bitcoin-cli for -help, help and RPC
|
||||
# as bitcoin-cli might not be in $PATH
|
||||
bitcoin_cli="$1"
|
||||
# save and use original argument to invoke komodo-cli for -help, help and RPC
|
||||
# as komodo-cli might not be in $PATH
|
||||
komodo_cli="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n = cur prev words cword
|
||||
@ -62,7 +62,7 @@ _zcash_cli() {
|
||||
if ((cword > 3)); then
|
||||
case ${words[cword-3]} in
|
||||
addmultisigaddress)
|
||||
_zcash_accounts
|
||||
_komodo_accounts
|
||||
return 0
|
||||
;;
|
||||
getbalance|gettxout|importaddress|importpubkey|importprivkey|listreceivedbyaccount|listreceivedbyaddress|listsinceblock)
|
||||
@ -82,12 +82,17 @@ _zcash_cli() {
|
||||
COMPREPLY=( $( compgen -W "add remove" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
fundrawtransaction|getblock|getblockheader|getmempoolancestors|getmempooldescendants|getrawtransaction|gettransaction|listaccounts|listreceivedbyaccount|listreceivedbyaddress|sendrawtransaction|z_importkey)
|
||||
fundrawtransaction|getblock|getblockheader|getmempoolancestors|getmempooldescendants|getrawtransaction|gettransaction|listaccounts|listreceivedbyaccount|listreceivedbyaddress|sendrawtransaction)
|
||||
COMPREPLY=( $( compgen -W "true false" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
# KMD does not have viewing keys, yet
|
||||
# z_importkey|z_importviewingkey)
|
||||
# COMPREPLY=( $( compgen -W "yes no whenkeyisnew" -- "$cur" ) )
|
||||
# return 0
|
||||
# ;;
|
||||
move|setaccount)
|
||||
_zcash_accounts
|
||||
_komodo_accounts
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -103,7 +108,7 @@ _zcash_cli() {
|
||||
return 0
|
||||
;;
|
||||
getaccountaddress|getaddressesbyaccount|getbalance|getnewaddress|getreceivedbyaccount|listtransactions|move|sendfrom|sendmany)
|
||||
_zcash_accounts
|
||||
_komodo_accounts
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
@ -127,12 +132,12 @@ _zcash_cli() {
|
||||
|
||||
# only parse -help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
||||
helpopts=$($bitcoin_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
helpopts=$($komodo_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
fi
|
||||
|
||||
# only parse help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
|
||||
commands=$(_zcash_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
|
||||
commands=$(_komodo_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')
|
||||
fi
|
||||
|
||||
COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) )
|
||||
@ -145,7 +150,7 @@ _zcash_cli() {
|
||||
;;
|
||||
esac
|
||||
} &&
|
||||
complete -F _zcash_cli zcash-cli
|
||||
complete -F _komodo_cli komodo-cli
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
@ -1,15 +1,15 @@
|
||||
# bash programmable completion for bitcoin-tx(1)
|
||||
# bash programmable completion for komodo-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.
|
||||
|
||||
_bitcoin_tx() {
|
||||
_komodo_tx() {
|
||||
local cur prev words=() cword
|
||||
local bitcoin_tx
|
||||
local komodo_tx
|
||||
|
||||
# save and use original argument to invoke bitcoin-tx for -help
|
||||
# save and use original argument to invoke komodo-tx for -help
|
||||
# it might not be in $PATH
|
||||
bitcoin_tx="$1"
|
||||
komodo_tx="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n =: cur prev words cword
|
||||
@ -27,15 +27,15 @@ _bitcoin_tx() {
|
||||
|
||||
if [[ "$cword" == 1 || ( "$prev" != "-create" && "$prev" == -* ) ]]; then
|
||||
# only options (or an uncompletable hex-string) allowed
|
||||
# parse bitcoin-tx -help for options
|
||||
# parse komodo-tx -help for options
|
||||
local helpopts
|
||||
helpopts=$($bitcoin_tx -help | sed -e '/^ -/ p' -e d )
|
||||
helpopts=$($komodo_tx -help | sed -e '/^ -/ p' -e d )
|
||||
COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
|
||||
else
|
||||
# only commands are allowed
|
||||
# parse -help for commands
|
||||
local helpcmds
|
||||
helpcmds=$($bitcoin_tx -help | sed -e '1,/Commands:/d' -e 's/=.*/=/' -e '/^ [a-z]/ p' -e d )
|
||||
helpcmds=$($komodo_tx -help | sed -e '1,/Commands:/d' -e 's/=.*/=/' -e '/^ [a-z]/ p' -e d )
|
||||
COMPREPLY=( $( compgen -W "$helpcmds" -- "$cur" ) )
|
||||
fi
|
||||
|
||||
@ -46,7 +46,7 @@ _bitcoin_tx() {
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _bitcoin_tx zcash-tx
|
||||
complete -F _komodo_tx komodo-tx
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
@ -1,16 +1,16 @@
|
||||
# bash programmable completion for zcashd(1)
|
||||
# bash programmable completion for komodod(1)
|
||||
# Copyright (c) 2012-2017 The Bitcoin Core developers
|
||||
# Copyright (c) 2016-2017 The Zcash developers
|
||||
# Copyright (c) 2016-2017 The komodo developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
_zcashd() {
|
||||
_komodod() {
|
||||
local cur prev words=() cword
|
||||
local bitcoind
|
||||
local komodod
|
||||
|
||||
# save and use original argument to invoke zcashd for -help
|
||||
# save and use original argument to invoke komodod for -help
|
||||
# it might not be in $PATH
|
||||
bitcoind="$1"
|
||||
komodod="$1"
|
||||
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n = cur prev words cword
|
||||
@ -21,7 +21,7 @@ _zcashd() {
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
-datadir=*)
|
||||
-datadir=*|-exportdir=*)
|
||||
cur="${cur#*=}"
|
||||
_filedir -d
|
||||
return 0
|
||||
@ -34,7 +34,7 @@ _zcashd() {
|
||||
# only parse -help if senseful
|
||||
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
||||
local helpopts
|
||||
helpopts=$($bitcoind -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
helpopts=$($komodod -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
||||
COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
|
||||
fi
|
||||
|
||||
@ -46,7 +46,7 @@ _zcashd() {
|
||||
;;
|
||||
esac
|
||||
} &&
|
||||
complete -F _zcashd zcashd
|
||||
complete -F _komodod komodod
|
||||
|
||||
# Local variables:
|
||||
# mode: shell-script
|
Loading…
x
Reference in New Issue
Block a user