Changeset View
Changeset View
Standalone View
Standalone View
contrib/bitcoin-cli.bash-completion
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | case "$cur" in | ||||
return 0 | return 0 | ||||
;; | ;; | ||||
-*=*) # prevent nonsense completions | -*=*) # prevent nonsense completions | ||||
return 0 | return 0 | ||||
;; | ;; | ||||
*) | *) | ||||
local helpopts commands | local helpopts commands | ||||
# only parse -help if senseful | # only parse -help if sensible | ||||
if [[ -z "$cur" || "$cur" =~ ^- ]]; then | if [[ -z "$cur" || "$cur" =~ ^- ]]; then | ||||
helpopts=$($bitcoin_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' ) | helpopts=$($bitcoin_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' ) | ||||
fi | fi | ||||
# only parse help if senseful | # only parse help if sensible | ||||
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then | if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then | ||||
commands=$(_bitcoin_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }') | commands=$(_bitcoin_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }') | ||||
fi | fi | ||||
COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) ) | COMPREPLY=( $( compgen -W "$helpopts $commands" -- "$cur" ) ) | ||||
# Prevent space if an argument is desired | # Prevent space if an argument is desired | ||||
if [[ $COMPREPLY == *= ]]; then | if [[ $COMPREPLY == *= ]]; then | ||||
Show All 15 Lines |