Merge #11597: [trivial] Fix error messages in CFeeBumper
[bitcoinplatinum.git] / contrib / bitcoin-tx.bash-completion
bloba83d2979ed3a8f11edea358937e8d5d359d58b4c
1 # bash programmable completion for bitcoin-tx(1)
2 # Copyright (c) 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 _bitcoin_tx() {
7     local cur prev words=() cword
8     local bitcoin_tx
10     # save and use original argument to invoke bitcoin-tx for -help
11     # it might not be in $PATH
12     bitcoin_tx="$1"
14     COMPREPLY=()
15     _get_comp_words_by_ref -n =: cur prev words cword
17     case "$cur" in
18         load=*:*)
19             cur="${cur#load=*:}"
20             _filedir
21             return 0
22             ;;
23         *=*)    # prevent attempts to complete other arguments
24             return 0
25             ;;
26     esac
28     if [[ "$cword" == 1 || ( "$prev" != "-create" && "$prev" == -* ) ]]; then
29         # only options (or an uncompletable hex-string) allowed
30         # parse bitcoin-tx -help for options
31         local helpopts
32         helpopts=$($bitcoin_tx -help | sed -e '/^  -/ p' -e d )
33         COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
34     else
35         # only commands are allowed
36         # parse -help for commands
37         local helpcmds
38         helpcmds=$($bitcoin_tx -help | sed -e '1,/Commands:/d' -e 's/=.*/=/' -e '/^  [a-z]/ p' -e d )
39         COMPREPLY=( $( compgen -W "$helpcmds" -- "$cur" ) )
40     fi
42     # Prevent space if an argument is desired
43     if [[ $COMPREPLY == *= ]]; then
44         compopt -o nospace
45     fi
47     return 0
48 } &&
49 complete -F _bitcoin_tx bitcoin-tx
51 # Local variables:
52 # mode: shell-script
53 # sh-basic-offset: 4
54 # sh-indent-comment: t
55 # indent-tabs-mode: nil
56 # End:
57 # ex: ts=4 sw=4 et filetype=sh