Merge #11965: qa: Note on test order in test_runner
[bitcoinplatinum.git] / contrib / bitcoind.bash-completion
blobcccd4bde0d33d9dae39a23b53e2816ae5f1c5464
1 # bash programmable completion for bitcoind(1) and bitcoin-qt(1)
2 # Copyright (c) 2012-2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 _bitcoind() {
7     local cur prev words=() cword
8     local bitcoind
10     # save and use original argument to invoke bitcoind for -help
11     # it might not be in $PATH
12     bitcoind="$1"
14     COMPREPLY=()
15     _get_comp_words_by_ref -n = cur prev words cword
17     case "$cur" in
18         -conf=*|-pid=*|-loadblock=*|-rootcertificates=*|-rpccookiefile=*|-wallet=*)
19             cur="${cur#*=}"
20             _filedir
21             return 0
22             ;;
23         -datadir=*)
24             cur="${cur#*=}"
25             _filedir -d
26             return 0
27             ;;
28         -*=*)   # prevent nonsense completions
29             return 0
30             ;;
31         *)
33             # only parse -help if sensible
34             if [[ -z "$cur" || "$cur" =~ ^- ]]; then
35                 local helpopts
36                 helpopts=$($bitcoind -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }' )
37                 COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
38             fi
40             # Prevent space if an argument is desired
41             if [[ $COMPREPLY == *= ]]; then
42                 compopt -o nospace
43             fi
44             return 0
45             ;;
46     esac
47 } &&
48 complete -F _bitcoind bitcoind bitcoin-qt
50 # Local variables:
51 # mode: shell-script
52 # sh-basic-offset: 4
53 # sh-indent-comment: t
54 # indent-tabs-mode: nil
55 # End:
56 # ex: ts=4 sw=4 et filetype=sh