-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathcompletion.zsh
More file actions
341 lines (302 loc) · 9.06 KB
/
Copy pathcompletion.zsh
File metadata and controls
341 lines (302 loc) · 9.06 KB
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
329
330
331
332
333
334
335
336
337
338
339
340
341
#compdef crystal
_crystal() {
_crystal_commands() {
local -a commands
commands=(
"init:generate new crystal project"
"build:build an executable"
"clear_cache:clear the compiler cache"
"docs:generate documentation"
"env:print Crystal environment information"
"eval:eval code from args or standard input"
"play:starts playground server"
"run:build and run program"
"spec:build and run specs (in spec directory)"
"tool:run a tool"
"help:show help"
"version:show version"
)
_describe -t commands 'Crystal command' commands
}
local -a help_args
help_args=(
'(-h --help)'{-h,--help}'[show help]'
)
local -a version_args
version_args=(
'(-v --version)'{-v,--version}'[show version]'
)
local -a no_color_args
no_color_args=(
'(--no-color)--no-color[disable colored output]'
)
local -a prelude_args
prelude_args=(
'(--prelude)--prelude[use given file as prelude]'
)
local -a exec_args
exec_args=(
'(\*)'{-D+,--define=}'[define a compile-time flag]:'
'(--error-trace)--error-trace[show full error trace]'
'(-s --stats)'{-s,--stats}'[enable statistics output]'
'(-t --time)'{-t,--time}'[enable execution time output]'
'(-p --progress)'{-p,--progress}'[enable progress output]'
)
local -a format_args
format_args=(
'(-f --format)'{-f,--format}'[output format text (default) or json]:'
)
local -a debug_args
debug_args=(
'(-d --debug)'{-d,--debug}'[add full symbolic debug info]'
'(--no-debug)--no-debug[skip any symbolic debug info]'
)
local -a release_args
release_args=(
'(--release)--release[compile in release mode]'
)
local -a cursor_args
cursor_args=(
'(-c --cursor)'{-c,--cursor}'[cursor location with LOC as path/to/file.cr:line:column]:LOC'
)
local -a include_exclude_args
include_exclude_args=(
'(-i --include)'{-i,--include}'[Include path in output]'
'(-i --exclude)'{-i,--exclude}'[Exclude path in output]'
)
local -a stdin_filename_args
stdin_filename_args=(
'(--stdin-filename)--stdin-filename[source file name to be read from STDIN]'
)
local -a programfile
programfile='*:Crystal File:_files -g "*.cr(.)"'
# TODO make 'emit' allow completion with more than one
local -a shared_run_build
shared_run_build=(
$programfile
$help_args
$no_color_args
$prelude_args
$format_args
$exec_args
$debug_args
$release_args
'(--emit)--emit[comma separated list of types of output for the compiler to emit]:foo:(asm llvm-bc llvm-ir obj)'
'(--x86-asm-syntax)--x86-asm-syntax[X86 dialect for --emit-asm: att (default), intel]:'
"(--ll)--ll[dump ll to Crystal's cache directory ]"
'(--link-flags)--link-flags[additional flags to pass to the linker]:'
'(--mcpu)--mcpu[target specific cpu type]:'
'(--mattr)--mattr[target specific features]:'
"(--no-codegen)--no-codegen[don't do code generation]"
'(-o --output)'{-o,--output}'[output filename]:'
'(--single-module)--single-module[generate a single llvm module]'
'(--threads)--threads[maximum number of threads to use]'
'(--verbose)--verbose[display executed commands]'
)
# TODO add help text for name and dir
_crystal-init() {
_arguments \
'1:type:(lib app)' &&
ret=0
}
_crystal-build() {
_arguments \
$shared_run_build \
'(--cross-compile)--cross-compile[cross-compile FLAGS]:' \
'(--target)--target[target triple]:' &&
ret=0
}
_crystal-env() {
_arguments \
'(--help)--help[prints help]' \
'1:type:(CRYSTAL_CACHE_DIR CRYSTAL_PATH CRYSTAL_VERSION CRYSTAL_OPTS)' &&
ret=0
}
_crystal-eval() {
_arguments \
$help_args \
$no_color_args \
$exec_args \
$debug_args \
$release_args &&
ret=0
}
_crystal-play() {
_arguments \
$programfile \
'(--port)--port[PORT]:' \
'(--binding)--binding[HOST]:' \
'(--verbose)--verbose[display detailed information of executed code]' \
'(-h --help)'{-h,--help}'[show help]' &&
ret=0
}
_crystal-run() {
_arguments \
$shared_run_build &&
ret=0
}
_crystal-spec() {
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$debug_args \
$release_args &&
ret=0
}
_crystal-tool() {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
command)
local -a commands
commands=(
"context:show context for given location"
"dependencies:show tree of required source files"
"expand:show macro expansion for given location"
"flags:print all macro 'flag?' values"
"format:format project, directories and/or files"
"hierarchy:show type hierarchy"
"implementations:show implementations for given call in location"
"macro_code_coverage:generate a macro code coverage report"
"types:show type of main variables"
"unreachable:show methods that are never called"
)
_describe -t commands 'Crystal tool command' commands
_arguments $help_args
;;
options)
case $line[1] in
context)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$format_args \
$prelude_args \
$stdin_filename_args \
$cursor_args
;;
dependencies)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
'(-f --format)'{-f,--format}'[output format 'tree' (default), 'flat', 'dot', or 'mermaid']:' \
$prelude_args \
$stdin_filename_args \
$include_exclude_args
;;
expand)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$format_args \
$prelude_args \
$stdin_filename_args \
$cursor_args
;;
flags)
_arguments \
$programfile \
$no_color_args \
$help_args
;;
format)
_arguments \
$programfile \
$help_args \
$no_color_args \
$include_exclude_args \
'(--check)--check[checks that formatting code produces no changes]' \
'(--show-backtrace)--show-backtrace[show backtrace on a bug (used only for debugging)]'
;;
hierarchy)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$format_args \
$prelude_args \
$stdin_filename_args \
'(-e)-e[filter types by NAME regex]:'
;;
implementations)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$format_args \
$prelude_args \
$cursor_args \
$stdin_filename_args
;;
unreachable)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$include_exclude_args \
'(-f --format)'{-f,--format}'[output format: text (default), json, csv, codecov]:' \
$prelude_args \
'(--check)--check[exits with error if there is any unreachable code]' \
'(--tallies)--tallies[print reachable methods and their call counts as well]' \
$stdin_filename_args
;;
macro_code_coverage)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$include_exclude_args \
'(-f --format)'{-f,--format}'[output format: codecov (default)]:' \
$prelude_args \
$stdin_filename_args
;;
types)
_arguments \
$programfile \
$help_args \
$no_color_args \
$exec_args \
$format_args \
$prelude_args \
$stdin_filename_args
;;
esac
;;
esac
}
local curcontext=$curcontext ret=1
declare -A opt_args
_arguments -C \
$help_args \
$version_args \
'1:sub-command: _alternative "subcommands:sub command:_crystal_commands" "files:file:_files -g \*.cr\(-.\)"' \
'*::arg:->cmd' && ret=0
case $state in
cmd)
if ((CURRENT == 1)); then
else
curcontext="${curcontext%:*:*}:crystal-$words[1]:"
if ! _call_function ret _crystal-$words[1]; then
_default && ret=0
fi
return ret
fi
;;
esac
}
_crystal