-
Notifications
You must be signed in to change notification settings - Fork 1
/
_cleos
328 lines (305 loc) · 12.2 KB
/
_cleos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#compdef cleos
# ------------------------------------------------------------------------------
# License
# -------
#
# The MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for cleos
# * Repo: https://github.com/OWDIN/cleos-zsh-completion
# * Reference:
# - https://developers.eos.io/eosio-nodeos/docs/cleos-overview
# - http://zsh.sourceforge.net/Doc/Release/Completion-System.html
# - `man zshcompsys`
#
# ------------------------------------------------------------------------------
# Recommended ZSH Configuration
# -------
#
# Add options to .zshrc
# zstyle ':completion:*' verbose yes
# zstyle ':completion:*' group-name ''
# zstyle ':completion:*:descriptions' format $'\e[00;34m%d'
# zstyle ':completion:*:messages' format $'\e[00;31m%d'
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * CHANN (https://github.com/channprj)
#
# ------------------------------------------------------------------------------
_main_commands=(
"convert:Pack and unpack transactions"
"create:Create various items, on and off the blockchain"
"get:Retrieve various items and information from the blockchain"
"multisig:Multisig contract commands"
"net:Interact with local p2p network connections"
"push:Push arbitrary transactions to the blockchain"
"set:Set or update blockchain state"
"sign:Sign a transaction"
"sudo:Sudo contract commands"
"system:Send eosio.system contract action to the blockchain"
"transfer:Transfer EOS from account to account"
"version:Retrieve version information"
"wallet:Interact with local wallet"
)
_cleos_commands() {
_describe 'Command Line Interface to EOSIO Client' _main_commands
}
_cleos() {
local context state state_descr line ret=1
typeset -A opt_args
_arguments \
"(-h --help)"{-h,--help}"[Print this help message and exit]" \
"(-u --url)"{-u,--url}"[TEXT=http://127.0.0.1:8888/ the http/https URL where nodeos is running]" \
"--wallet-url[TEXT=http://127.0.0.1:8900/ the http/https URL where keosd is running]" \
"(-r --header)"{-r,--header}"[pass specific HTTP header; repeat this option to pass multiple headers]" \
"(-n --no-verify)"{-n,--no-verify}"[don't verify peer certificate when using HTTPS]" \
"(-v --verbose)"{-v,--verbose}"[output verbose actions on error]" \
"--print-request[print HTTP request to STDERR]" \
"--print-response[print HTTP response to STDERR]" \
'1: :_cleos_commands' \
"*:: :->command_args" \
&& ret=0
case $state in
(command_args)
case $words[1] in
(convert)
case $words[2] in
(pack_action_data | pack_transaction | unpack_action_data | unpack_transaction)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Pack and unpack transactions" \
"pack_action_data[From json action data to packed form]" \
"pack_transaction[From plain signed json to packed form]" \
"unpack_action_data[From packed to json action data form]" \
"unpack_transaction[From packed to plain signed json form]" \
&& ret=0
;;
esac
;;
(create)
case $words[2] in
(account | key)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Create various items, on and off the blockchain" \
"key[Create a new keypair and print the public and private keys]" \
"account[Create an account, buy ram, stake for bandwidth for the account]" \
&& ret=0
;;
esac
;;
(get)
case $words[2] in
(info | block | account | code | abi | table | currency | accounts | servants | transaction | actions | schedule | transaction_id)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Retrieve various items and information from the blockchain" \
"info[Get current blockchain information]" \
"block[Retrieve a full block from the blockchain]" \
"account[Retrieve an account from the blockchain]" \
"code[Retrieve the code and ABI for an account]" \
"abi[Retrieve the ABI for an account]" \
"table[Retrieve the contents of a database table]" \
"currency[Retrieve information related to standard currencies]" \
"accounts[Retrieve accounts associated with a public key]" \
"servants[Retrieve accounts which are servants of a given account]" \
"transaction[Retrieve a transaction from the blockchain]" \
"actions[Retrieve all actions with specific account name referenced in authorization or receiver]" \
"schedule[Retrieve the producer schedule]" \
"transaction_id[Get transaction id given transaction object]" \
&& ret=0
;;
esac
;;
(multisig)
case $words[2] in
(propose | propose_trx | review | approve | unapprove | cancel | exec)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Multisig contract commands" \
"propose[Propose action]" \
"propose_trx[Propose transaction]" \
"review[Review transaction]" \
"approve[Approve proposed transaction]" \
"unapprove[Unapprove proposed transaction]" \
"cancel[Cancel proposed transaction]" \
"exec[Execute proposed transaction]" \
&& ret=0
;;
esac
;;
(net)
case $words[2] in
(connect | disconnect | status | peers)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Interact with local p2p network connections" \
"connect[start a new connection to a peer]" \
"disconnect[close an existing connection]" \
"status[status of existing connection]" \
"peers[status of all existing peers]" \
&& ret=0
;;
esac
;;
(push)
case $words[2] in
(action | transaction | transactions)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Push arbitrary transactions to the blockchain" \
"action[Push a transaction with a single action]" \
"transaction[Push an arbitrary JSON transaction]" \
"transactions[Push an array of arbitrary JSON transactions]" \
&& ret=0
;;
esac
;;
(set)
case $words[2] in
(code | abi | contract | account | action)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Set or update blockchain state" \
"code[Create or update the code on an account]" \
"abi[Create or update the abi on an account]" \
"contract[Create or update the contract on an account]" \
"account[set or update blockchain account state]" \
"action[set or update blockchain action state]" \
&& ret=0
;;
esac
;;
(sign)
case $words[2] in
(*)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
esac
;;
(sudo)
case $words[2] in
(exec)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Sudo contract commands" \
"exec[Execute a transaction while bypassing authorization checks]" \
&& ret=0
;;
esac
;;
(system)
case $words[2] in
(newaccount | regproducer | unregprod | voteproducer | listproducers | delegatebw | undelegatebw | listbw | bidname | bidnameinfo | buyram | sellram | claimrewards | regproxy | unregproxy | canceldelay)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Send eosio.system contract action to the blockchain" \
"newaccount[Create an account, buy ram, stake for bandwidth for the account]" \
"regproducer[Register a new producer]" \
"unregprod[Unregister an existing producer]" \
"voteproducer[Vote for a producer]" \
"listproducers[List producers]" \
"delegatebw[Delegate bandwidth]" \
"undelegatebw[Undelegate bandwidth]" \
"listbw[List delegated bandwidth]" \
"bidname[Name bidding]" \
"bidnameinfo[Get bidname info]" \
"buyram[Buy RAM]" \
"sellram[Sell RAM]" \
"claimrewards[Claim producer rewards]" \
"regproxy[Register an account as a proxy (for voting)]" \
"unregproxy[Unregister an account as a proxy (for voting)]" \
"canceldelay[Cancel a delayed transaction]" \
&& ret=0
;;
esac
;;
(transfer)
case $words[2] in
(*)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
esac
;;
(version)
case $words[2] in
(client)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Retrieve version information" \
"client[Retrieve version information of the client]" \
&& ret=0
;;
esac
;;
(wallet)
case $words[2] in
(create | open | lock | lock_all | unlock | import | remove_key | create_key | list | keys | private_keys | stop)
_message "`cleos $words -h 2>&1 | sed '1d'`"
;;
(*)
_values "Interact with local wallet" \
"create[Create a new wallet locally]" \
"open[Open an existing wallet]" \
"lock[Lock wallet]" \
"lock_all[Lock all unlocked wallets]" \
"unlock[Unlock wallet]" \
"import[Import private key into wallet]" \
"remove_key[Remove key from wallet]" \
"create_key[Create private key within wallet]" \
"list[List opened wallets, * = unlocked]" \
"keys[List of public keys from all unlocked wallets]" \
"private_keys[List of private keys from an unlocked wallet in wif or PVT_R1 format]" \
"stop[Stop keosd (doesn't work with nodeos)]" \
&& ret=0
;;
esac
;;
esac
;;
esac
return ret
}
_cleos "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et