2016-07-11 11:02:41 +02:00
|
|
|
# bash programmable completion for dashd(1) and dash-qt(1)
|
2019-12-31 18:35:41 +01:00
|
|
|
# Copyright (c) 2012-2019 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2012-05-23 20:26:45 +02:00
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2015-04-05 23:56:58 +02:00
|
|
|
_dashd() {
|
2012-05-23 20:26:45 +02:00
|
|
|
local cur prev words=() cword
|
2015-04-05 23:56:58 +02:00
|
|
|
local dashd
|
2012-05-23 20:26:45 +02:00
|
|
|
|
2016-07-11 11:02:41 +02:00
|
|
|
# save and use original argument to invoke dashd for -help
|
|
|
|
# it might not be in $PATH
|
2015-04-05 23:56:58 +02:00
|
|
|
dashd="$1"
|
2012-05-23 20:26:45 +02:00
|
|
|
|
|
|
|
COMPREPLY=()
|
|
|
|
_get_comp_words_by_ref -n = cur prev words cword
|
|
|
|
|
|
|
|
case "$cur" in
|
2022-04-25 11:01:47 +02:00
|
|
|
-conf=*|-pid=*|-loadblock=*|-rpccookiefile=*|-wallet=*)
|
2012-05-23 20:26:45 +02:00
|
|
|
cur="${cur#*=}"
|
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-datadir=*)
|
|
|
|
cur="${cur#*=}"
|
|
|
|
_filedir -d
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-*=*) # prevent nonsense completions
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
|
2017-08-16 00:45:58 +02:00
|
|
|
# only parse -help if sensible
|
2012-05-23 20:26:45 +02:00
|
|
|
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
2016-07-11 11:02:41 +02:00
|
|
|
local helpopts
|
|
|
|
helpopts=$($dashd -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
|
|
|
|
COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
|
2012-05-23 20:26:45 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Prevent space if an argument is desired
|
|
|
|
if [[ $COMPREPLY == *= ]]; then
|
|
|
|
compopt -o nospace
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2016-07-11 11:02:41 +02:00
|
|
|
} &&
|
|
|
|
complete -F _dashd dashd dash-qt
|
2012-05-23 20:26:45 +02:00
|
|
|
|
|
|
|
# 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
|