]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/swiftpm/_swift
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / swiftpm / _swift
1 #compdef swift
2 local context state state_descr line
3 typeset -A opt_args
4
5 _swift() {
6     _arguments -C \
7         '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
8         '(-): :->command' \
9         '(-)*:: :->arg' && return
10
11     case $state in
12         (command)
13             local tools
14             tools=(
15                 'build:build sources into binary products'
16                 'run:build and run an executable product'
17                 'package:perform operations on Swift packages'
18                 'test:build and run tests'
19             )
20             _alternative \
21                 'tools:common:{_describe "tool" tools }' \
22                 'compiler: :_swift_compiler' && _ret=0
23             ;;
24         (arg)
25             case ${words[1]} in
26                 (build)
27                     _swift_build
28                     ;;
29                 (run)
30                     _swift_run
31                     ;;
32                 (package)
33                     _swift_package
34                     ;;
35                 (test)
36                     _swift_test
37                     ;;
38                 (*)
39                     _swift_compiler
40                     ;;
41             esac
42             ;;
43     esac
44 }
45
46 _swift_dependency() {
47     local dependencies
48     dependencies=( $(swift package completion-tool list-dependencies) )
49     _describe '' dependencies
50 }
51
52 _swift_executable() {
53     local executables
54     executables=( $(swift package completion-tool list-executables) )
55     _describe '' executables
56 }
57
58 # Generates completions for swift build
59 #
60 # In the final compdef file, set the following file header:
61 #
62 #     #compdef _swift_build
63 #     local context state state_descr line
64 #     typeset -A opt_args
65 _swift_build() {
66     arguments=(
67         "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
68         "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
69         "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
70         "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
71         "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
72         "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
73         "(--chdir -C)"{--chdir,-C}"[]: :_files"
74         "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
75         "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
76         "--disable-prefetching[]"
77         "--skip-update[Skip updating dependencies from their remote during a resolution]"
78         "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
79         "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
80         "--version[]"
81         "--destination[]: :_files"
82         "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
83         "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
84         "--static-swift-stdlib[Link Swift stdlib statically]"
85         "--force-resolved-versions[]"
86         "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
87         "--enable-index-store[Enable indexing-while-building feature]"
88         "--disable-index-store[Disable indexing-while-building feature]"
89         "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
90         "--enable-parseable-module-interfaces[]"
91         "--trace-resolver[]"
92         "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
93         "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
94         "--build-tests[Build both source and test targets]"
95         "--product[Build the specified product]:Build the specified product: "
96         "--target[Build the specified target]:Build the specified target: "
97         "--show-bin-path[Print the binary output path]"
98     )
99     _arguments $arguments && return
100 }
101
102 # Generates completions for swift run
103 #
104 # In the final compdef file, set the following file header:
105 #
106 #     #compdef _swift_run
107 #     local context state state_descr line
108 #     typeset -A opt_args
109 _swift_run() {
110     arguments=(
111         ":The executable to run:_swift_executable"
112         "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
113         "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
114         "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
115         "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
116         "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
117         "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
118         "(--chdir -C)"{--chdir,-C}"[]: :_files"
119         "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
120         "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
121         "--disable-prefetching[]"
122         "--skip-update[Skip updating dependencies from their remote during a resolution]"
123         "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
124         "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
125         "--version[]"
126         "--destination[]: :_files"
127         "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
128         "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
129         "--static-swift-stdlib[Link Swift stdlib statically]"
130         "--force-resolved-versions[]"
131         "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
132         "--enable-index-store[Enable indexing-while-building feature]"
133         "--disable-index-store[Disable indexing-while-building feature]"
134         "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
135         "--enable-parseable-module-interfaces[]"
136         "--trace-resolver[]"
137         "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
138         "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
139         "--skip-build[Skip building the executable product]"
140         "--build-tests[Build both source and test targets]"
141         "--repl[Launch Swift REPL for the package]"
142     )
143     _arguments $arguments && return
144 }
145
146 # Generates completions for swift package
147 #
148 # In the final compdef file, set the following file header:
149 #
150 #     #compdef _swift_package
151 #     local context state state_descr line
152 #     typeset -A opt_args
153 _swift_package() {
154     arguments=(
155         "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
156         "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
157         "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
158         "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
159         "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
160         "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
161         "(--chdir -C)"{--chdir,-C}"[]: :_files"
162         "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
163         "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
164         "--disable-prefetching[]"
165         "--skip-update[Skip updating dependencies from their remote during a resolution]"
166         "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
167         "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
168         "--version[]"
169         "--destination[]: :_files"
170         "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
171         "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
172         "--static-swift-stdlib[Link Swift stdlib statically]"
173         "--force-resolved-versions[]"
174         "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
175         "--enable-index-store[Enable indexing-while-building feature]"
176         "--disable-index-store[Disable indexing-while-building feature]"
177         "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
178         "--enable-parseable-module-interfaces[]"
179         "--trace-resolver[]"
180         "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
181         "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
182         '(-): :->command'
183         '(-)*:: :->arg'
184     )
185     _arguments $arguments && return
186     case $state in
187         (command)
188             local modes
189             modes=(
190                 'completion-tool:Completion tool (for shell completions)'
191                 'dump-package:Print parsed Package.swift as JSON'
192                 'describe:Describe the current package'
193                 'clean:Delete build artifacts'
194                 'show-dependencies:Print the resolved dependency graph'
195                 'init:Initialize a new package'
196                 'unedit:Remove a package from editable mode'
197                 'tools-version:Manipulate tools version of the current package'
198                 'fetch:'
199                 'resolve:Resolve package dependencies'
200                 'reset:Reset the complete cache/build directory'
201                 'generate-xcodeproj:Generates an Xcode project'
202                 'edit:Put a package in editable mode'
203                 'config:Manipulate configuration of the package'
204                 'update:Update package dependencies'
205             )
206             _describe "mode" modes
207             ;;
208         (arg)
209             case ${words[1]} in
210                 (completion-tool)
211                     _swift_package_completion-tool
212                     ;;
213                 (dump-package)
214                     _swift_package_dump-package
215                     ;;
216                 (describe)
217                     _swift_package_describe
218                     ;;
219                 (clean)
220                     _swift_package_clean
221                     ;;
222                 (show-dependencies)
223                     _swift_package_show-dependencies
224                     ;;
225                 (init)
226                     _swift_package_init
227                     ;;
228                 (unedit)
229                     _swift_package_unedit
230                     ;;
231                 (tools-version)
232                     _swift_package_tools-version
233                     ;;
234                 (fetch)
235                     _swift_package_fetch
236                     ;;
237                 (resolve)
238                     _swift_package_resolve
239                     ;;
240                 (reset)
241                     _swift_package_reset
242                     ;;
243                 (generate-xcodeproj)
244                     _swift_package_generate-xcodeproj
245                     ;;
246                 (edit)
247                     _swift_package_edit
248                     ;;
249                 (config)
250                     _swift_package_config
251                     ;;
252                 (update)
253                     _swift_package_update
254                     ;;
255             esac
256             ;;
257     esac
258 }
259
260 _swift_package_completion-tool() {
261     arguments=(
262         ": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
263     )
264     _arguments $arguments && return
265 }
266
267 _swift_package_dump-package() {
268     arguments=(
269     )
270     _arguments $arguments && return
271 }
272
273 _swift_package_describe() {
274     arguments=(
275         "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
276     )
277     _arguments $arguments && return
278 }
279
280 _swift_package_clean() {
281     arguments=(
282     )
283     _arguments $arguments && return
284 }
285
286 _swift_package_show-dependencies() {
287     arguments=(
288         "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
289     )
290     _arguments $arguments && return
291 }
292
293 _swift_package_init() {
294     arguments=(
295         "--type[empty|library|executable|system-module|manifest]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
296         "--name[Provide custom package name]:Provide custom package name: "
297     )
298     _arguments $arguments && return
299 }
300
301 _swift_package_unedit() {
302     arguments=(
303         ":The name of the package to unedit:_swift_dependency"
304         "--force[Unedit the package even if it has uncommitted and unpushed changes.]"
305     )
306     _arguments $arguments && return
307 }
308
309 _swift_package_tools-version() {
310     arguments=(
311         "--set[Set tools version of package to the given value]:Set tools version of package to the given value: "
312         "--set-current[Set tools version of package to the current tools version in use]"
313     )
314     _arguments $arguments && return
315 }
316
317 _swift_package_fetch() {
318     arguments=(
319     )
320     _arguments $arguments && return
321 }
322
323 _swift_package_resolve() {
324     arguments=(
325         ":The name of the package to resolve:_swift_dependency"
326         "--version[The version to resolve at]:The version to resolve at: "
327         "--branch[The branch to resolve at]:The branch to resolve at: "
328         "--revision[The revision to resolve at]:The revision to resolve at: "
329     )
330     _arguments $arguments && return
331 }
332
333 _swift_package_reset() {
334     arguments=(
335     )
336     _arguments $arguments && return
337 }
338
339 _swift_package_generate-xcodeproj() {
340     arguments=(
341         "--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
342         "--enable-code-coverage[Enable code coverage in the generated project]"
343         "--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
344         "--legacy-scheme-generator[Use the legacy scheme generator]"
345         "--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
346         "--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
347     )
348     _arguments $arguments && return
349 }
350
351 _swift_package_edit() {
352     arguments=(
353         ":The name of the package to edit:_swift_dependency"
354         "--revision[The revision to edit]:The revision to edit: "
355         "--branch[The branch to create]:The branch to create: "
356         "--path[Create or use the checkout at this path]:Create or use the checkout at this path:_files"
357     )
358     _arguments $arguments && return
359 }
360
361 _swift_package_config() {
362     arguments=(
363         '(-): :->command'
364         '(-)*:: :->arg'
365     )
366     _arguments $arguments && return
367     case $state in
368         (command)
369             local modes
370             modes=(
371                 'unset-mirror:Remove an existing mirror'
372                 'get-mirror:Print mirror configuration for the given package dependency'
373                 'set-mirror:Set a mirror for a dependency'
374             )
375             _describe "mode" modes
376             ;;
377         (arg)
378             case ${words[1]} in
379                 (unset-mirror)
380                     _swift_package_config_unset-mirror
381                     ;;
382                 (get-mirror)
383                     _swift_package_config_get-mirror
384                     ;;
385                 (set-mirror)
386                     _swift_package_config_set-mirror
387                     ;;
388             esac
389             ;;
390     esac
391 }
392
393 _swift_package_config_unset-mirror() {
394     arguments=(
395         "--package-url[The package dependency url]:The package dependency url: "
396         "--mirror-url[The mirror url]:The mirror url: "
397     )
398     _arguments $arguments && return
399 }
400
401 _swift_package_config_get-mirror() {
402     arguments=(
403         "--package-url[The package dependency url]:The package dependency url: "
404     )
405     _arguments $arguments && return
406 }
407
408 _swift_package_config_set-mirror() {
409     arguments=(
410         "--package-url[The package dependency url]:The package dependency url: "
411         "--mirror-url[The mirror url]:The mirror url: "
412     )
413     _arguments $arguments && return
414 }
415
416 _swift_package_update() {
417     arguments=(
418     )
419     _arguments $arguments && return
420 }
421
422 # Generates completions for swift test
423 #
424 # In the final compdef file, set the following file header:
425 #
426 #     #compdef _swift_test
427 #     local context state state_descr line
428 #     typeset -A opt_args
429 _swift_test() {
430     arguments=(
431         "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
432         "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
433         "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
434         "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
435         "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
436         "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
437         "(--chdir -C)"{--chdir,-C}"[]: :_files"
438         "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
439         "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
440         "--disable-prefetching[]"
441         "--skip-update[Skip updating dependencies from their remote during a resolution]"
442         "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
443         "--disable-package-manifest-caching[Disable caching Package.swift manifests]"
444         "--version[]"
445         "--destination[]: :_files"
446         "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
447         "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
448         "--static-swift-stdlib[Link Swift stdlib statically]"
449         "--force-resolved-versions[]"
450         "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
451         "--enable-index-store[Enable indexing-while-building feature]"
452         "--disable-index-store[Disable indexing-while-building feature]"
453         "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
454         "--enable-parseable-module-interfaces[]"
455         "--trace-resolver[]"
456         "(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
457         "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
458         "--skip-build[Skip building the test target]"
459         "(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]"
460         "--generate-linuxmain[Generate LinuxMain.swift entries for the package]"
461         "--parallel[Run the tests in parallel.]"
462         "--num-workers[Number of tests to execute in parallel.]:Number of tests to execute in parallel.: "
463         "(--specifier -s)"{--specifier,-s}"[]: : "
464         "--xunit-output[]: :_files"
465         "--filter[Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>]:Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>: "
466         "--enable-code-coverage[Test with code coverage enabled]"
467     )
468     _arguments $arguments && return
469 }
470
471 _swift_compiler() {
472 }
473
474 _swift