This repository was archived by the owner on Nov 23, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path_zig
More file actions
441 lines (421 loc) · 23.9 KB
/
_zig
File metadata and controls
441 lines (421 loc) · 23.9 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
#compdef zig
local -a __zig_commands
__zig_commands=(
'build:Build project from build.zig'
'fetch:Copy a package into global cache and print its hash'
'init:Initialize a Zig package in the current directory'
'build-exe:Create executable from source or object files'
'build-lib:Create library from source or object files'
'build-obj:Create object from source or object files'
'test:Perform unit testing'
'run:Create executable and run immediately'
'ast-check:Look for simple compile errors in any set of files'
'fmt:Reformat Zig source into canonical form'
'reduce:Minimize a bug report'
'translate-c:Convert C code to Zig code'
'ar:Use Zig as a drop-in archiver'
'cc:Use Zig as a drop-in C compiler'
'c++:Use Zig as a drop-in C++ compiler'
'dlltool:Use Zig as a drop-in dlltool.exe'
'lib:Use Zig as a drop-in lib.exe'
'ranlib:Use Zig as a drop-in ranlib'
'objcopy:Use Zig as a drop-in objcopy'
'rc:Use Zig as a drop-in rc.exe'
'env:Print lib path, std path, cache directory, and version'
'help:Print this help and exit'
'std:View standard library documentation in a browser'
'libc:Display native libc paths file or validate one'
'targets:List available compilation targets'
'version:Print version number and exit'
'zen:Print Zen of Zig and exit'
)
__zig_general_options=(
'--color[Enable or disable colored error messages]: :(on off auto)'
'-j[Limit concurrent jobs (default is to use all CPU cores)]:int'
'-fincremental[Enable incremental compilation]'
'-fno-incremental[Disable incremental compilation]'
'-femit-bin=[(default) Output machine code]:path:_files -/'
'-fno-emit-bin[Do not output machine code]:'
'-femit-asm[Output .s (assembly code)]:path:_files -/'
'-fno-emit-asm[(default) Do not output .s (assembly code)]:'
'-femit-llvm-ir[Produce a .ll file with LLVM IR (requires LLVM extensions)]:path:_files -/'
'-fno-emit-llvm-ir[(default) Do not produce a .ll file with LLVM IR]:'
'-femit-llvm-bc[Produce a LLVM module as a .bc file (requires LLVM extensions)]:path:_files -/'
'-fno-emit-llvm-bc[(default) Do not produce a LLVM module as a .bc file]'
'-femit-h[Generate a C header file (.h)]:path:_files -/'
'-fno-emit-h[(default) Do not generate a C header file (.h)]:'
'-femit-docs[Create a docs/ dir with html documentation]:path:_files -/'
'-fno-emit-docs[(default) Do not produce docs/ dir with html documentation]:'
'-femit-implib[(default) Produce an import .lib when building a Windows DLL]:path:_files -/'
'-fno-emit-implib[Do not produce an import .lib when building a Windows DLL]:'
'--show-builtin[Output the source of @import("builtin") then exit]:'
'--cache-dir[Override the local cache directory]:path:_files -/'
'--global-cache-dir[Override the global cache directory]:path:_files -/'
'--zig-lib-dir[Override path to Zig installation lib directory]:path:_files -/'
)
__zig_compile_options=(
'--name[Override root name (not a file path)]:name'
'--libc[Provide a file which specifies libc paths]:dir:_files'
'-x[Treat subsequent input files as having type <language>]:language'
'--dep[Add an entry to the next module''s import table]:import'
'-M[Create a module based on the current per-module settings. The first module is the main module. "std" can be configured by omitting src After a -M argument, per-module settings are reset.]:name'
'--error-limit[Set the maximum amount of distinct error values]:int'
'-fllvm[Force using LLVM as the codegen backend]'
'-fno-llvm[Prevent using LLVM as a codegen backend]'
'-flibllvm[Force using the LLVM API in the codegen backend]'
'-fno-libllvm[Prevent using the LLVM API in the codegen backend]'
'-fclang[Force using Clang as the C/C++ compilation backend]'
'-fno-clang[Prevent using Clang as the C/C++ compilation backend]'
'-fPIE[Force-enable Position Independent Executable]'
'-fno-PIE[Force-disable Position Independent Executable]'
'-flto[Force-enable Link Time Optimization (requires LLVM extensions)]'
'-fno-lto[Force-disable Link Time Optimization]'
'-fdll-export-fns[Mark exported functions as DLL exports (Windows)]'
'-fno-dll-export-fns[Force-disable marking exported functions as DLL exports]'
'-freference-trace[How many lines of reference trace should be shown per compile error]:int'
'-fno-reference-trace[Disable reference trace]'
'-ffunction-sections[Places each function in a separate section]'
'-fno-function-sections[All functions go into same section]'
'-fdata-sections[Places each data in a separate section]'
'-fno-data-sections[All data go into same section]'
'-fstructured-cfg[(SPIR-V) force SPIR-V kernels to use structured control flow]'
'-fno-structured-cfg[(SPIR-V) force SPIR-V kernels to not use structured control flow]'
'-mexec-model=[(WASI) Execution model]:mode:(command reactor)'
'-municode[(Windows) Use wmain/wWinMain as entry point]'
'-target[<arch><sub>-<os>-<abi> see the targets command]:target'
'-O-[Choose what to optimize for]:mode:((
Debug\:"(default) Optimizations off, safety on"
ReleaseFast\:"Optimizations on, safety off"
ReleaseSafe\:"Optimizations on, safety on"
ReleaseSmall\:"Optimize for small binary, safety off"
))'
'-ofmt=[Override target object format]:mode:((
elf\:"Executable and Linking Format"
c\:"Compile to C source code"
wasm\:"WebAssembly"
coff\:"Common Object File Format (Windows)"
macho\:"macOS relocatables"
spriv\:"Standard, Portable Intermediate Representation V (SPIR-V)"
plan9\:"Plan 9 from Bell Labs object format"
hex\:"Intel IHEX (planned)"
raw\:"Dump machine code directly (planned)"
))'
'-mcpu[Specify target CPU and feature set]:cpu'
'-mcmodel=[Limit range of code and data virtual addresses]:model:(default extreme kernel large medany medium medlov medmid normal small tiny)'
'-mred-zone[Force-enable the "red-zone"]'
'-mno-red-zone[Force-disable the "red-zone"]'
'-fomit-frame-pointer[Omit the stack frame pointer]'
'-fno-omit-frame-pointer[Store the stack frame pointer]'
'-fPIC[Force-enable Position Independent Code]'
'-fno-PIC[Force-disable Position Independent Code]'
'-fstack-check[Enable stack probing in unsafe builds]'
'-fno-stack-check[Disable stack probing in safe builds]'
'-fstack-protector[Enable stack protection in unsafe builds]'
'-fno-stack-protector[Disable stack protection in safe builds]'
'-fvalgrind[Include valgrind client requests in release builds]'
'-fno-valgrind[Omit valgrind client requests in debug builds]'
'-fsanitize-c=[Enable C undefined behavior detection in unsafe builds]:mode:(trap full)'
'-fno-sanitize-c[Disable C undefined behavior detection in safe builds]'
'-fsanitize-thread[Enable Thread Sanitizer]'
'-fno-sanitize-thread[Disable Thread Sanitizer]'
'-ffuzz[Enable fuzz testing instrumentation]'
'-fno-fuzz[Disable fuzz testing instrumentation]'
'-fbuiltin[Enable implicit builtin knowledge of functions]'
'-fno-builtin[Disable implicit builtin knowledge of functions]'
'-funwind-tables[Always produce unwind table entries for all functions]'
'-fasync-unwind-tables[Always produce asynchronous unwind table entries for all functions]'
'-fno-unwind-tables[Never produce unwind table entries]'
'-ferror-tracing[Enable error tracing in ReleaseFast mode]'
'-fno-error-tracing[Disable error tracing in Debug and ReleaseSafe mode]'
'-fsingle-threaded[Code assumes there is only one thread]'
'-fno-single-threaded[Code may not assume there is only one thread]'
'-fstrip[Omit debug symbols]'
'-fno-strip[Keep debug symbols]'
'-idirafter[Add directory to AFTER include search path]:dir:_files -/'
'-isystem[Add directory to SYSTEM include search path]:dir:_files -/'
'-I-[Add directory to include search path]:dir:_files -/'
'-D[Define C \[macro\] to \[value\] (1 if \[value\] omitted)]:string'
'-cflags[Set extra flags for the next positional C source files]:[flags]'
'-rcincludes=[Set the type of includes to use when compiling .rc source files]:type:((
any\:"(default) Use msvc if available, fall back to gnu"
msvc\:"Use msvc include paths (must be present on the system)"
gnu\:"Use mingw include paths (distributed with Zig)"
none\:"Do not use any autodetected include paths"
))'
)
__zig_link_options=(
'-T-[Use a custom linker script]:script:_files'
'--version-script[Provide a version .map file]:path:_files -/'
'--undefined-version[Allow version scripts to refer to undefined symbols]'
'--no-undefined-version[(default) Disallow version scripts from referring to undefined symbols]'
'--enable-new-dtags[Use the new behavior for dynamic tags (RUNPATH)]'
'--disable-new-dtags[Use the old behavior for dynamic tags (RPATH)]'
'--dynamic-linker[Set the dynamic interpreter path (usually ld.so)]:path:_files -/'
'--sysroot[Set the system root directory (usually /)]:path:_files -/'
'--version[Dynamic library semver]:string'
'-fentry=[Set the entrypoint symbol name]:string'
'-fno-entry[Do not output any entry point]'
'--force_undefined[Specify the symbol must be defined for the link to succeed]:name'
'-fsoname=[Override the default SONAME value]:name'
'-fno-soname[Disable emitting a SONAME]'
'-flld[Force using LLD as the linker]'
'-fno-lld[Prevent using LLD as the linker]'
'-fcompiler-rt[Always include compiler-rt symbols in output]'
'-fno-compiler-rt[Prevent including compiler-rt symbols in output]'
'-fubsan-rt[Always include ubsan-rt symbols in the output]'
'-fno-ubsan-rt[Prevent including ubsan-rt symbols in the output]'
'-rdynamic[Add all symbols to the dynamic symbol table]'
'-feach-lib-rpath[Ensure adding rpath for each used dynamic library]'
'-fno-each-lib-rpath[Prevent adding rpath for each used dynamic library]'
'-fallow-shlib-undefined[Allows undefined symbols in shared libraries]'
'-fno-allow-shlib-undefined[Disallows undefined symbols in shared libraries]'
'-fallow-so-scripts[Allows .so files to be GNU ld scripts]'
'-fno-allow-so-scripts[(default) .so files must be ELF files]'
'--build-id=[At a minor link-time expense, embeds a build ID in binaries]:style:((
fast\:"8-byte non-cryptographic hash (COFF, ELF, WASM)"
sha1, tree\:"20-byte cryptographic hash (ELF, WASM)"
md5\:"16-byte cryptographic hash (ELF)"
uuid\:"16-byte random UUID (ELF, WASM)"
0x[hexstring]\:"Constant ID, maximum 32 bytes (ELF, WASM)"
none\:"(default) No build ID"
))'
'--eh-frame-hdr[Enable C++ exception handling by passing --eh-frame-hdr to linker]'
'--no-eh-frame-hdr[Disable C++ exception handling by passing --no-eh-frame-hdr to linker]'
'--emit-relocs[Enable output of relocation sections for post build tools]'
'-z[Set linker extension flags]: :((
nodelete\:"Indicate that the object cannot be deleted from a process"
notext\:"Permit read-only relocations in read-only segments"
defs\:"Force a fatal error if any undefined symbols remain"
undefs\:"Reverse of -z defs"
origin\:"Indicate that the object must have its origin processed"
nocopyreloc\:"Disable the creation of copy relocations"
now\:"(default) Force all relocations to be processed on load"
lazy\:"Do not force all relocations to be processed on load"
relro\:"(default) Force all relocations to be read-only after processing"
norelro\:"Do not force all relocations to be read-only after processing"
common-page-size=\:"Set the common page size for ELF binaries"
max-page-size=\:"Set the max page size for ELF binaries"
))'
'-dynamic[Force output to be dynamically linked]'
'-static[Force output to be statically linked]'
'-Bsymbolic[Bind global references locally]'
'--compress-debug-sections=[Debug section compression settings]: :((
none\:"No compression"
zlib\:"Compression with deflate/inflate"
zstd\:"Compression with zstandard"
))'
'--gc-sections[Force removal of functions and data that are unreachable by the entry point or exported symbols]'
'--no-gc-sections[Do not force removal of unreachable functions and data]'
'--sort-section=[Sort wildcard section patterns by ''name'' or ''alignment'']:value'
'--subsystem[(Windows) /SUBSYSTEM:<subsystem> to the linker]:subsystem'
'--stack[Override default stack size]:int'
'--image-base[Set base address for executable image]:int'
'-install_name=[(Darwin) add dylibs install name]:string'
'--entitlements[(Darwin) add path to entitlements file for embedding in code signature]:path:_files -/'
'-pagezero_size[(Darwin) size of the __PAGEZERO segment in hexadecimal notation]:int'
'-headerpad[(Darwin) set minimum space for future expansion of the load commands in hexadecimal notation]:int'
'-headerpad_max_install_names[(Darwin) set enough space as if all paths were MAXPATHLEN]'
'-dead_strip[(Darwin) remove functions and data that are unreachable by the entry point or exported symbols]'
'-dead_strip_dylibs[(Darwin) remove dylibs that are unreachable by the entry point or exported symbols]'
'-ObjC[(Darwin) force load all members of static archives that implement an Objective-C class or category]'
'--import-memory[(WebAssembly) import memory from the environment]'
'--export-memory[(WebAssembly) export memory to the host (Default unless --import-memory used)]'
'--import-symbols[(WebAssembly) import missing symbols from the host environment]'
'--import-table[(WebAssembly) import function table from the host environment]'
'--export-table[(WebAssembly) export function table to the host environment]'
'--initial-memory=[(WebAssembly) initial size of the linear memory]:int'
'--max-memory=[(WebAssembly) maximum size of the linear memory]:int'
'--shared-memory[(WebAssembly) use shared linear memory]'
'--global-base=[(WebAssembly) where to start to place global data]:int'
'-l-[Link against system library (only if actually used)]:library:__zig_library'
'--library[Link against system library (only if actually used)]:library:__zig_library'
'-needed-l-[Link against system library (even if unused)]:library:__zig_library'
'--needed-library[Link against system library (even if unused)]:library:__zig_library'
'-weak-l-[(Darwin) link against system library and mark it and all referenced symbols as weak]:library:__zig_library'
'-L-[Add a directory to the library search path]:d:_files -/'
'--library-directory[Add a directory to the library search path]:d:_files -/'
'-search_paths_first[For each library search path, check for dynamic lib then static lib before proceeding to next path]'
'-search_paths_first_static[For each library search path, check for static lib then dynamic lib before proceeding to next path]'
'-search_dylibs_first[Search for dynamic libs in all library search paths, then static libs]'
'-search_static_first[Search for static libs in all library search paths, then dynamic libs]'
'-search_dylibs_only[Only search for dynamic libs]'
'-search_static_only[Only search for static libs]'
'-rpath[Add directory to the runtime library search path]:path:_files -/'
'-framework[(Darwin) link against framework]:framework'
'-needed_framework[(Darwin) link against framework (even if unused)]:framework'
'-weak_framework[(Darwin) link against framework and mark it and all referenced symbols as weak]:framework'
'-F[(Darwin) add search path for frameworks]:dir:_files -/'
'--export=[(WebAssembly) Force a symbol to be exported]:string'
)
__zig_debug_options=(
'-fopt-bisect-limit=[Only run <limit> first LLVM optimization passes]:int'
'-ftime-report[Print timing diagnostics]'
'-fstack-report[Print stack size diagnostics]'
'--verbose-link[Display linker invocations]'
'--verbose-cc[Display C compiler invocations]'
'--verbose-air[Enable compiler debug output for Zig AIR]'
'--verbose-intern-pool[Enable compiler debug output for InternPool]'
'--verbose-generic-instances[Enable compiler debug output for generic instance generation]'
'--verbose-llvm-ir[Enable compiler debug output for LLVM IR]'
'--verbose-llvm-bc=[Enable compiler debug output for unoptimized LLVM BC]:path'
'--verbose-cimport[Enable compiler debug output for C imports]'
'--verbose-llvm-cpu-features[Enable compiler debug output for LLVM CPU features]'
'--debug-log[Enable printing debug/info log messages for scope]:string'
'--debug-compile-errors[Crash with helpful diagnostics at the first compile error]'
'--debug-link-snapshot[Enable dumping of the linkers state in JSON format]'
'--debug-rt[Debug compiler runtime libraries]'
'*:files:__zig_files'
)
__zig_test_options=(
'--test-filter[Skip tests that do not match filter]:string'
'--test-name-prefix[Add prefix to all tests]:string'
'--test-cmd[Specify test execution command one arg at a time]:string'
'--test-cmd-bin[Appends test binary path to test cmd args]'
'--test-evented-io[Runs the test in evented I/O mode]'
'--test-no-exec[Compiles test binary without running it]'
'--test-runner[Specify a custom test runner]:path'
)
__zig_files() {
_files -g "*.{zig,o,obj,lib,a,so,dll,dylib,tbd,s,S,c,cpp,C,cc,cxx,c++,bc,def,rc,res}"
}
__zig_library() {
_wanted libraries expl library \
compadd - \
${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(:t:fr:s/lib//)
}
__zig_build() {
steps=()
args=(
'-p-[Override default install prefix]:path:_files -/'
'--prefix[Override default install prefix]:path:_files -/'
'--prefix-lib-dir[Override default library directory path]:path:_files -/'
'--prefix-exe-dir[Override default executable directory path]:path:_files -/'
'--prefix-include-dir[Override default include directory path]:path:_files -/'
'--release=[Request release mode, optionally specifying a preferred optimization mode: fast, safe, small]:mode:(fast safe small)'
'-fdarling[Enable integration with system-installed Darling to execute macOS programs on Linux hosts]'
'-fno-darling[(default) Disable integration with system-installed Darling to execute macOS programs on Linux hosts]'
'-fqemu[Enable integration with system-installed QEMU to execute foreign-architecture programs on Linux hosts]'
'-fno-qemu[(default) Disable integration with system-installed QEMU to execute foreign-architecture programs on Linux hosts]'
'--libc-runtimes[Enhances QEMU integration by providing dynamic libc (e.g. glibc or musl) built for multiple foreign architectures, allowing execution of non-native]:dir:_files'
'-frosetta[Rely on Rosetta to execute x86_64 programs on ARM64 macOS hosts]'
'-fno-rosetta[(default) Do not rely on Rosetta to execute x86_64 programs on ARM64 macOS hosts]'
'-fwasmtime[Enable integration with system-installed wasmtime to execute WASI binaries]'
'-fno-wasmtime[(default) disable integration with system-installed wasmtime to execute WASI binaries]'
'-fwine[Enable integration with system-installed Wine to execute Windows programs on Linux hosts]'
'-fno-wine[(default) disable integration with system-installed Wine to execute Windows programs on Linux hosts]'
'--verbose[Print commands before executing them]'
'--color[Enable or disable colored error messages]: :(on off auto)'
'--prominent-compile-errors[Output compile errors formatted for a human to read]'
'--summary[Control the printing of the build summary]:mode:((
all\:"Print the build summary in its entirety"
new\:"Omit cached steps"
failures\:"(Default) Only print failed steps"
none\:"Do not print the build summary"
))'
'-j[Limit concurrent jobs (default is to use all CPU cores)]:int'
'--maxrss[Limit memory usage (default is to use available memory)]:int'
'--skip-oom-steps[Instead of failing, skip steps that would exceed --maxrss]'
'--fetch=[Fetch dependency tree (optionally choose laziness) and exit]:mode:((
needed\:"(Default) Lazy dependencies are fetched as needed"
all\:"Lazy dependencies are always fetched"
))'
'--watch[Continuously rebuild when source files are modified]'
'--fuzz[Continuously search for unit test failures]'
'--debounce[Delay before rebuilding after changed file detected]:int'
'-fincremental[Enable incremental compilation]'
'-fno-incremental[Disable incremental compilation]'
'--sysroot[Set the system root directory (usually /)]:path:_files -/'
'--search-prefix[Add a path to look for binaries, libraries, headers]:path:_files -/'
'--libc[Provide a file which specifies libc paths]:dir:_files'
'--system[Disable package fetching; enable all integrations]:name'
'-fsys=[Enable a system integration]:name'
'-fno-sys=[Disable a system integration]:name'
'-freference-trace=[How many lines of reference trace should be shown per compile error]:int'
'-fno-reference-trace[Disable reference trace]'
'-fallow-so-scripts[Allows .so files to be GNU ld scripts]'
'-fno-allow-so-scripts[(default) .so files must be ELF files]'
'--build-file[Override path to build.zig]:file'
'--cache-dir[Override path to local Zig cache directory]:path'
'--global-cache-dir[Override path to global Zig cache directory]:path'
'--zig-lib-dir[Override path to Zig lib directory]:path'
'--build-runner[Override path to build runner]:file'
'--seed[For shuffling dependency traversal order (default: random)]:int'
'--build-id=[At a minor link-time expense, embeds a build ID in binaries]:style:((
fast\:"8-byte non-cryptographic hash (COFF, ELF, WASM)"
sha1, tree\:"20-byte cryptographic hash (ELF, WASM)"
md5\:"16-byte cryptographic hash (ELF)"
uuid\:"16-byte random UUID (ELF, WASM)"
0x[hexstring]\:"Constant ID, maximum 32 bytes (ELF, WASM)"
none\:"(default) No build ID"
))'
'--debug-log[Enable debugging the compiler]:scope'
'--debug-pkg-config[Fail if unknown pkg-config flags encountered]'
'--debug-rt[Debug compiler runtime libraries]'
'--verbose-link[Enable compiler debug output for linking]'
'--verbose-air[Enable compiler debug output for Zig AIR]'
'--verbose-llvm-ir=[Enable compiler debug output for LLVM IR]:file'
'--verbose-llvm-bc=[Enable compiler debug output for LLVM BC]:file'
'--verbose-cimport[Enable compiler debug output for C imports]'
'--verbose-cc[Enable compiler debug output for C compilation]'
'--verbose-llvm-cpu-features[Enable compiler debug output for LLVM CPU features]'
)
in_options=false
in_project_options=false
help=$($__zig_exe build --help 2> /dev/null | tail -n +4)
while IFS= read -r line ; do
if [ "$in_options" = "false" ]; then
if [ -z "$line" ]; then
in_options=true
continue
fi
# step (default) description -> step:(default) description
steps+=("$(sed -r 's/^ *([^ ]+)( \(default\))? +(.*) *$/\1:\3\2/' <<<"$line")")
elif [ "$in_project_options" = "false" ]; then
if [ "$line" = "Project-Specific Options:" ]; then
in_project_options=true
continue
fi
elif [ "$line" = "System Integration Options:" ]; then
break
else
if [ -n "$(grep ' -' <<<"$line")" ]; then
# -Dflag=[arg] description -> -Dflag=[description]:arg
args+=("$(sed -r 's/^ *([^\[ ]+) ?(\[([^]]*)\])? *(.+) *$/\1[\4]:\3/' <<<"$line")")
fi
fi
done <<< $help
if [ -z "$(grep "^-" <<<$words[$CURRENT])" ]; then
_describe 'step' steps
else
_arguments ${args[@]}
fi
}
__zig_exe=$words[1]
_arguments \
"1: :{_describe 'command' __zig_commands}" \
"*:: :->args"
case $state in
args)
case $words[1] in
build-exe | build-lib | build-obj | run | translate-c)
_arguments $__zig_general_options $__zig_compile_options $__zig_link_options $__zig_debug_options
;;
test)
_arguments $__zig_general_options $__zig_compile_options $__zig_link_options $__zig_debug_options $__zig_test_options
;;
fmt)
_arguments \
'--stdin[Format code from stdin; output to stdout]:' \
'--color[Enable or disable colored error messages]: :(on off auto)' \
'--check[List non-conforming files and exit with an error if the list is non-empty]' \
'--ast-check[Run zig ast-check on every file]' \
'--exclude[Exclude file or directory from formatting]:path:_files -/' \
'--zon[Treat all input files as ZON, regardless of file extension]' \
'*:files:_files -g "*.{zig,zon}"'
;;
build)
__zig_build
;;
esac
;;
esac