limenka-cli.zsh raw
1 #compdef limenka-cli
2 # zsh completion for limenka-cli(1)
3 # DO NOT EDIT THIS FILE BY HAND -- THIS WILL FAIL THE FUNCTIONAL TEST tool_cli_completion
4 # This file is auto-generated by the functional test tool_cli_completion.
5 # If you want to modify this file, modify test/functional/tool_cli_completion.py and re-autogenerate
6 # this file via the --overwrite test flag.
7
8 # Copyright (c) 2012-2024 The Limenka developers
9 # Distributed under the MIT software license, see the accompanying
10 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
11
12 # call limenka-cli for RPC
13 _limenka_rpc() {
14 # determine already specified args necessary for RPC
15 local rpcargs=()
16 local -a words_array
17 words_array=(${(z)BUFFER})
18
19 for i in $words_array; do
20 case "$i" in
21 -conf=*|-datadir=*|-regtest|-rpc*|-testnet|-testnet4)
22 rpcargs+=("$i")
23 ;;
24 esac
25 done
26
27 $limenka_cli "${rpcargs[@]}" "$@"
28 }
29
30 _limenka-cli() {
31 local context state line
32 local limenka_cli="$words[1]"
33
34 if (( CURRENT > 6 )); then
35 case ${words[CURRENT-5]} in
36 descriptorprocesspsbt)
37 _values 'arg' 'false' 'true'
38 return 0
39 ;;
40 esac
41 fi
42
43 if (( CURRENT > 5 )); then
44 case ${words[CURRENT-4]} in
45 createpsbt|createrawtransaction|descriptorprocesspsbt|setban)
46 _values 'arg' 'false' 'true'
47 return 0
48 ;;
49 signrawtransactionwithkey)
50 _values 'arg' 'ALL' 'ALL|ANYONECANPAY' 'NONE' 'NONE|ANYONECANPAY' 'SINGLE' 'SINGLE|ANYONECANPAY'
51 return 0
52 ;;
53 esac
54 fi
55
56 if (( CURRENT > 4 )); then
57 case ${words[CURRENT-3]} in
58 addnode|converttopsbt|getdescriptoractivity|gettxout|gettxoutsetinfo)
59 _values 'arg' 'false' 'true'
60 return 0
61 ;;
62 esac
63 fi
64
65 if (( CURRENT > 3 )); then
66 case ${words[CURRENT-2]} in
67 converttopsbt|decoderawtransaction|finalizepsbt|getblockheader|getmempoolancestors|getmempooldescendants|getrawmempool|listmempooltransactions)
68 _values 'arg' 'false' 'true'
69 return 0
70 ;;
71 addnode)
72 _values 'arg' 'add' 'onetry' 'remove'
73 return 0
74 ;;
75 setban)
76 _values 'arg' 'add' 'remove'
77 return 0
78 ;;
79 estimatesmartfee)
80 _values 'arg' 'CONSERVATIVE' 'ECONOMICAL' 'UNSET'
81 return 0
82 ;;
83 esac
84 fi
85
86 # Handle previous word completions
87 case "${words[CURRENT-1]}" in
88 dumptxoutset|importmempool|loadtxoutset)
89 _files
90 return 0
91 ;;
92 getrawmempool|setnetworkactive|setscriptthreadsenabled)
93 _values 'arg' 'false' 'true'
94 return 0
95 ;;
96 esac
97 # Handle current word completions
98 case "$words[CURRENT]" in
99 -conf=*)
100 local conf_path=${words[CURRENT]#-conf=}
101 _files -W ${conf_path:h} -g "*"
102 return 0
103 ;;
104 -datadir=*)
105 local datadir_path=${words[CURRENT]#-datadir=}
106 _files -/ -W ${datadir_path:h}
107 return 0
108 ;;
109 -*=*)
110 # prevent nonsense completions
111 return 0
112 ;;
113 *)
114 local helpopts commands
115 local -a opts
116
117 # only parse -help if sensible (empty or starts with -)
118 if [[ -z "$words[CURRENT]" || "$words[CURRENT]" == -* ]]; then
119 helpopts="$($limenka_cli -help 2>&1 | awk '$1 ~ /^-/ { sub(/=.*/, "="); print $1 }')"
120 opts+=(${(f)helpopts})
121 fi
122
123 # only parse help if sensible (empty or starts with letter)
124 if [[ -z "$words[CURRENT]" || "$words[CURRENT]" == [a-z]* ]]; then
125 commands="$(_limenka_rpc help 2>/dev/null | awk '$1 ~ /^[a-z]/ { print $1; }')"
126 opts+=(${(f)commands})
127 fi
128
129 _describe 'limenka-cli options and commands' opts
130
131 return 0
132 ;;
133 esac
134 }
135
136 # Function is now defined and will be called by zsh completion system
137
138 # Local variables:
139 # mode: shell-script
140 # sh-basic-offset: 4
141 # sh-indent-comment: t
142 # indent-tabs-mode: nil
143 # End:
144 # ex: ts=4 sw=4 et filetype=sh
145