]>
Commit | Line | Data |
---|---|---|
1 | # bash programmable completion for zcash-tx(1) | |
2 | # Copyright (c) 2016 The Bitcoin Core developers | |
3 | # Copyright (c) 2016-2019 The Zcash developers | |
4 | # Distributed under the MIT software license, see the accompanying | |
5 | # file COPYING or https://www.opensource.org/licenses/mit-license.php . | |
6 | ||
7 | _zcash_tx() { | |
8 | local cur prev words=() cword | |
9 | local zcash_tx | |
10 | ||
11 | # save and use original argument to invoke zcash-tx for -help | |
12 | # it might not be in $PATH | |
13 | zcash_tx="$1" | |
14 | ||
15 | COMPREPLY=() | |
16 | _get_comp_words_by_ref -n =: cur prev words cword | |
17 | ||
18 | case "$cur" in | |
19 | load=*:*) | |
20 | cur="${cur#load=*:}" | |
21 | _filedir | |
22 | return 0 | |
23 | ;; | |
24 | *=*) # prevent attempts to complete other arguments | |
25 | return 0 | |
26 | ;; | |
27 | esac | |
28 | ||
29 | if [[ "$cword" == 1 || ( "$prev" != "-create" && "$prev" == -* ) ]]; then | |
30 | # only options (or an uncompletable hex-string) allowed | |
31 | # parse zcash-tx -help for options | |
32 | local helpopts | |
33 | helpopts=$($zcash_tx -help | sed -e '/^ -/ p' -e d ) | |
34 | COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) ) | |
35 | else | |
36 | # only commands are allowed | |
37 | # parse -help for commands | |
38 | local helpcmds | |
39 | helpcmds=$($zcash_tx -help | sed -e '1,/Commands:/d' -e 's/=.*/=/' -e '/^ [a-z]/ p' -e d ) | |
40 | COMPREPLY=( $( compgen -W "$helpcmds" -- "$cur" ) ) | |
41 | fi | |
42 | ||
43 | # Prevent space if an argument is desired | |
44 | if [[ $COMPREPLY == *= ]]; then | |
45 | compopt -o nospace | |
46 | fi | |
47 | ||
48 | return 0 | |
49 | } && | |
50 | complete -F _zcash_tx zcash-tx | |
51 | ||
52 | # Local variables: | |
53 | # mode: shell-script | |
54 | # sh-basic-offset: 4 | |
55 | # sh-indent-comment: t | |
56 | # indent-tabs-mode: nil | |
57 | # End: | |
58 | # ex: ts=4 sw=4 et filetype=sh |