-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
_grpc_cli
217 lines (202 loc) · 9.28 KB
/
_grpc_cli
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
#compdef grpc_cli
# -----------------------------------------------------------------------------
# The BSD-3-Clause License
#
# Copyright (c) 2018, Koichi Shiraishi
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of que nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
#
# github.com/grpc/grpc
#
# grpc_cli: Warning: SetUsageMessage() never called
#
# Flags from /path/to/gflags-2.2.1/src/gflags.cc:
# -flagfile (load flags from file) type: string default: ""
# -fromenv (set flags from the environment [use 'export FLAGS_flag1=value'])
# type: string default: ""
# -tryfromenv (set flags from the environment if present) type: string
# default: ""
# -undefok (comma-separated list of flag names that it is okay to specify on
# the command line even if the program does not define a flag with that
# name. IMPORTANT: flags in this list that have arguments MUST use the
# flag=value format) type: string default: ""
#
# Flags from /path/to/gflags-2.2.1/src/gflags_completions.cc:
# -tab_completion_columns (Number of columns to use in output for tab
# completion) type: int32 default: 80
# -tab_completion_word (If non-empty, HandleCommandLineCompletions() will
# hijack the process and attempt to do bash-style command line flag
# completion on this value.) type: string default: ""
#
# Flags from /path/to/gflags-2.2.1/src/gflags_reporting.cc:
# -help (show help on all flags [tip: all flags can have two dashes])
# type: bool default: false currently: true
# -helpfull (show help on all flags -- same as -help) type: bool
# default: false
# -helpmatch (show help on modules whose name contains the specified substr)
# type: string default: ""
# -helpon (show help on the modules named by this flag value) type: string
# default: ""
# -helppackage (show help on all modules in the main package) type: bool
# default: false
# -helpshort (show help on only the main module for this program) type: bool
# default: false
# -helpxml (produce an xml version of help) type: bool default: false
# -version (show version and build info and exit) type: bool default: false
#
#
#
# Flags from test/cpp/util/cli_credentials.cc:
# -access_token (The access token that will be sent to the server to
# authenticate RPCs.) type: string default: ""
# -enable_ssl (Whether to use ssl/tls.) type: bool default: false
# -use_auth (Whether to create default google credentials.) type: bool
# default: false
#
# Flags from test/cpp/util/grpc_cli.cc:
# -outfile (Output file (default is stdout)) type: string default: ""
#
# Flags from test/cpp/util/grpc_tool.cc:
# -batch (Input contains multiple requests. Please do not use this to send
# more than a few RPCs. gRPC CLI has very different performance
# characteristics compared with normal RPC calls which make it unsuitable
# for loadtesting or significant production traffic.) type: bool
# default: false
# -binary_input (Input in binary format) type: bool default: false
# -binary_output (Output in binary format) type: bool default: false
# -infile (Input file (default is stdin)) type: string default: ""
# -l (Use a long listing format) type: bool default: false
# -metadata (Metadata to send to server, in the form of key1:val1:key2:val2)
# type: string default: ""
# -proto_path (Path to look for the proto file.) type: string default: "."
# -protofiles (Name of the proto file.) type: string default: ""
# -remotedb (Use server types to parse and format messages) type: bool
# default: true
#
# -----------------------------------------------------------------------------
function _grpc_cli() {
local context curcontext=$curcontext state line ret=1
declare -A opt_args
local -a commands
commands=(
'ls:List services'
'call:Call method'
'type:Print type'
'parse:Parse message'
'totext:Convert binary message to text'
'tobinary:Convert text message to binary'
'help:Print this message, or per-command usage'
)
local -a _global_flags
_global_flags=(
'-flagfile[load flags from file]:string'
"-fromenv[set flags from the environment (use 'export FLAGS_flag1=value')]:string"
'-tryfromenv[set flags from the environment if present]:string'
'-undefok[comma-separated list of flag names that it is okay to specify on the command line even if the program does not define a flag with that name]:flag=value'
'-tab_completion_columns[Number of columns to use in output for tab completion]:int32'
'-tab_completion_word[If non-empty, HandleCommandLineCompletions() will hijack the process and attempt to do bash-style command line flag completion on this value.]:string'
'-help[show help on all flags (tip: all flags can have two dashes]:bool'
'-helpfull[show help on all flags -- same as -help]:bool'
'-helpmatch[show help on modules whose name contains the specified substr]:string'
'-helpon[show help on the modules named by this flag value]:string'
'-helppackage[show help on all modules in the main package]:bool'
'-helpshort[show help on only the main module for this program]:bool'
'-helpxml[produce an xml version of help]:bool'
'-version[show version and build info and exit]:bool'
'-access_token[The access token that will be sent to the server to authenticate RPCs.]:string'
'-enable_ssl[Whether to use ssl/tls.]:bool'
'-use_auth[Whether to create default google credentials.]:bool'
'-outfile[Output file]:output file:_files'
'-batch[Input contains multiple requests. Please do not use this to send more than a few RPCs.]:bool'
'-binary_input[Input in binary format]:bool'
'-binary_output[Output in binary format]:bool'
'-infile[Input file]:input:_files'
'-l[Use a long listing format]:bool'
'-metadata[Metadata to send to server, in the form of key1:val1:key2:val2]:string'
'-proto_path[Path to look for the proto file.]:proto file:_files'
'-protofiles[Name of the proto file.]:proto name'
'-remotedb[Use server types to parse and format messages]:bool'
)
_arguments -C \
"1: :{_describe '$BIN command' commands}" \
${_global_flags[@]} \
'*:: :->args' \
&& ret=0
case $words[1] in
ls)
_arguments \
'--dir-mode[Run as if the directory the file was given, but only print the errors from the file.]' \
'--disable-format[Do not run formatting.]' \
'--disable-lint[Do not run linting.]' \
${_global_flags[@]} \
'*:proto file|dir:_files'
;;
call)
_arguments \
'--dir-mode[Run as if the directory the file was given, but only print the errors from the file.]' \
${_global_flags[@]} \
'1:proto file|dir:_files' \
'2:messagePath:_files' \
'3:data'
;;
type)
_arguments \
'--dir-mode[Run as if the directory the file was given, but only print the errors from the file.]' \
${_global_flags[@]} \
'1:proto file|dir:_files' \
'2:messagePath:_files'
;;
parse)
_arguments \
{-d,--diff}'[Write a diff instead of writing the formatted file to stdout.]' \
{-l,--lint}'[Write a lint error saying that the file is not formatted instead of writing the formatted file to stdout.]' \
{-w,--overwrite}'[Overwrite the existing file instead of writing the formatted file to stdout.]' \
${_global_flags[@]} \
'*:proto file|dir:_files'
;;
totext)
_arguments \
'--dir-mode[Run as if the directory the file was given, but only print the errors from the file.]' \
${_global_flags[@]} \
'1:proto file|dir:_files' \
'2:fieldPath:_files'
;;
tobinary)
_arguments \
${_global_flags[@]} \
'*:proto file|dir:_files'
;;
help)
_arguments "1: :{_describe 'command' commands -- topics}"
;;
esac
return ret
}
_grpc_cli "$*"
# vim:ft=zsh:et:sts=2:sw=2