_swift 21.1 KB
Newer Older
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
#compdef swift
local context state state_descr line
typeset -A opt_args

_swift() {
    _arguments -C \
        '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
        '(-): :->command' \
        '(-)*:: :->arg' && return

    case $state in
        (command)
            local tools
            tools=(
                'build:build sources into binary products'
                'run:build and run an executable product'
                'package:perform operations on Swift packages'
                'test:build and run tests'
            )
            _alternative \
                'tools:common:{_describe "tool" tools }' \
                'compiler: :_swift_compiler' && _ret=0
            ;;
        (arg)
            case ${words[1]} in
                (build)
                    _swift_build
                    ;;
                (run)
                    _swift_run
                    ;;
                (package)
                    _swift_package
                    ;;
                (test)
                    _swift_test
                    ;;
                (*)
                    _swift_compiler
                    ;;
            esac
            ;;
    esac
}

_swift_dependency() {
    local dependencies
    dependencies=( $(swift package completion-tool list-dependencies) )
    _describe '' dependencies
}

_swift_executable() {
    local executables
    executables=( $(swift package completion-tool list-executables) )
    _describe '' executables
}

# Generates completions for swift build
#
# In the final compdef file, set the following file header:
#
#     #compdef _swift_build
#     local context state state_descr line
#     typeset -A opt_args
_swift_build() {
    arguments=(
        "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
        "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
        "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
        "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
        "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
        "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
        "(--chdir -C)"{--chdir,-C}"[]: :_files"
        "--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
81
82
        "--version[]"
        "--destination[]: :_files"
        "(--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
86
87
88
89
90
        "--force-resolved-versions[]"
        "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
        "--enable-index-store[Enable indexing-while-building feature]"
        "--disable-index-store[Disable indexing-while-building feature]"
        "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
        "--enable-parseable-module-interfaces[]"
91
92
93
        "--trace-resolver[]"
        "(--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: "
        "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
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
        "--build-tests[Build both source and test targets]"
        "--product[Build the specified product]:Build the specified product: "
        "--target[Build the specified target]:Build the specified target: "
        "--show-bin-path[Print the binary output path]"
    )
    _arguments $arguments && return
}

# Generates completions for swift run
#
# In the final compdef file, set the following file header:
#
#     #compdef _swift_run
#     local context state state_descr line
#     typeset -A opt_args
_swift_run() {
    arguments=(
        ":The executable to run:_swift_executable"
        "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
        "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
        "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
        "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
        "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
        "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
        "(--chdir -C)"{--chdir,-C}"[]: :_files"
        "--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
126
127
        "--version[]"
        "--destination[]: :_files"
        "(--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
131
132
133
134
135
        "--force-resolved-versions[]"
        "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
        "--enable-index-store[Enable indexing-while-building feature]"
        "--disable-index-store[Disable indexing-while-building feature]"
        "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
        "--enable-parseable-module-interfaces[]"
136
137
138
        "--trace-resolver[]"
        "(--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: "
        "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
139
        "--skip-build[Skip building the executable product]"
140
141
        "--build-tests[Build both source and test targets]"
        "--repl[Launch Swift REPL for the package]"
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
    )
    _arguments $arguments && return
}

# Generates completions for swift package
#
# In the final compdef file, set the following file header:
#
#     #compdef _swift_package
#     local context state state_descr line
#     typeset -A opt_args
_swift_package() {
    arguments=(
        "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
        "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
        "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
        "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
        "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
        "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
        "(--chdir -C)"{--chdir,-C}"[]: :_files"
        "--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
169
170
        "--version[]"
        "--destination[]: :_files"
        "(--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
174
175
176
177
178
        "--force-resolved-versions[]"
        "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
        "--enable-index-store[Enable indexing-while-building feature]"
        "--disable-index-store[Disable indexing-while-building feature]"
        "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
        "--enable-parseable-module-interfaces[]"
179
180
181
        "--trace-resolver[]"
        "(--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: "
        "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
182
183
184
185
186
187
188
189
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments $arguments && return
    case $state in
        (command)
            local modes
            modes=(
190
191
                'completion-tool:Completion tool (for shell completions)'
                '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
196
197
                'init:Initialize a new package'
                'unedit:Remove a package from editable mode'
                'tools-version:Manipulate tools version of the current package'
198
                'fetch:'
199
200
201
                'resolve:Resolve package dependencies'
                'reset:Reset the complete cache/build directory'
                'generate-xcodeproj:Generates an Xcode project'
202
203
                'edit:Put a package in editable mode'
                'config:Manipulate configuration of the package'
204
                'update:Update package dependencies'
205
206
207
208
209
            )
            _describe "mode" modes
            ;;
        (arg)
            case ${words[1]} in
210
211
212
213
214
                (completion-tool)
                    _swift_package_completion-tool
                    ;;
                (dump-package)
                    _swift_package_dump-package
215
216
217
218
                    ;;
                (describe)
                    _swift_package_describe
                    ;;
219
220
                (clean)
                    _swift_package_clean
221
                    ;;
222
223
224
225
226
                (show-dependencies)
                    _swift_package_show-dependencies
                    ;;
                (init)
                    _swift_package_init
227
                    ;;
228
229
230
                (unedit)
                    _swift_package_unedit
                    ;;
231
232
                (tools-version)
                    _swift_package_tools-version
233
                    ;;
234
235
                (fetch)
                    _swift_package_fetch
236
                    ;;
237
238
239
240
241
242
243
244
                (resolve)
                    _swift_package_resolve
                    ;;
                (reset)
                    _swift_package_reset
                    ;;
                (generate-xcodeproj)
                    _swift_package_generate-xcodeproj
245
                    ;;
246
247
                (edit)
                    _swift_package_edit
248
                    ;;
249
250
251
                (config)
                    _swift_package_config
                    ;;
252
253
                (update)
                    _swift_package_update
254
255
256
257
258
259
                    ;;
            esac
            ;;
    esac
}

260
261
262
263
264
265
266
267
_swift_package_completion-tool() {
    arguments=(
        ": :{_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]'}"
    )
    _arguments $arguments && return
}

_swift_package_dump-package() {
268
269
270
271
272
    arguments=(
    )
    _arguments $arguments && return
}

273
_swift_package_describe() {
274
    arguments=(
275
        "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
276
277
278
279
    )
    _arguments $arguments && return
}

280
_swift_package_clean() {
281
282
283
284
285
    arguments=(
    )
    _arguments $arguments && return
}

286
_swift_package_show-dependencies() {
287
    arguments=(
288
289
290
291
292
293
294
295
296
        "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
    )
    _arguments $arguments && return
}

_swift_package_init() {
    arguments=(
        "--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]'}"
        "--name[Provide custom package name]:Provide custom package name: "
297
298
299
300
301
302
303
304
305
306
307
308
    )
    _arguments $arguments && return
}

_swift_package_unedit() {
    arguments=(
        ":The name of the package to unedit:_swift_dependency"
        "--force[Unedit the package even if it has uncommited and unpushed changes.]"
    )
    _arguments $arguments && return
}

309
_swift_package_tools-version() {
310
    arguments=(
311
312
        "--set[Set tools version of package to the given value]:Set tools version of package to the given value: "
        "--set-current[Set tools version of package to the current tools version in use]"
313
314
315
316
317
    )
    _arguments $arguments && return
}

_swift_package_fetch() {
318
319
320
321
322
    arguments=(
    )
    _arguments $arguments && return
}

323
_swift_package_resolve() {
324
    arguments=(
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
        ":The name of the package to resolve:_swift_dependency"
        "--version[The version to resolve at]:The version to resolve at: "
        "--branch[The branch to resolve at]:The branch to resolve at: "
        "--revision[The revision to resolve at]:The revision to resolve at: "
    )
    _arguments $arguments && return
}

_swift_package_reset() {
    arguments=(
    )
    _arguments $arguments && return
}

_swift_package_generate-xcodeproj() {
    arguments=(
        "--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
        "--enable-code-coverage[Enable code coverage in the generated project]"
        "--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
        "--legacy-scheme-generator[Use the legacy scheme generator]"
        "--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
        "--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
347
348
349
350
    )
    _arguments $arguments && return
}

351
_swift_package_edit() {
352
    arguments=(
353
354
355
356
        ":The name of the package to edit:_swift_dependency"
        "--revision[The revision to edit]:The revision to edit: "
        "--branch[The branch to create]:The branch to create: "
        "--path[Create or use the checkout at this path]:Create or use the checkout at this path:_files"
357
358
359
360
    )
    _arguments $arguments && return
}

361
_swift_package_config() {
362
    arguments=(
363
364
        '(-): :->command'
        '(-)*:: :->arg'
365
366
    )
    _arguments $arguments && return
367
368
369
370
371
372
    case $state in
        (command)
            local modes
            modes=(
                'unset-mirror:Remove an existing mirror'
                'get-mirror:Print mirror configuration for the given package dependency'
373
                'set-mirror:Set a mirror for a dependency'
374
375
376
377
378
379
380
381
382
383
384
            )
            _describe "mode" modes
            ;;
        (arg)
            case ${words[1]} in
                (unset-mirror)
                    _swift_package_config_unset-mirror
                    ;;
                (get-mirror)
                    _swift_package_config_get-mirror
                    ;;
385
386
387
                (set-mirror)
                    _swift_package_config_set-mirror
                    ;;
388
389
390
            esac
            ;;
    esac
391
392
}

393
_swift_package_config_unset-mirror() {
394
    arguments=(
395
396
        "--package-url[The package dependency url]:The package dependency url: "
        "--mirror-url[The mirror url]:The mirror url: "
397
398
399
400
    )
    _arguments $arguments && return
}

401
_swift_package_config_get-mirror() {
402
    arguments=(
403
        "--package-url[The package dependency url]:The package dependency url: "
404
405
406
407
    )
    _arguments $arguments && return
}

408
_swift_package_config_set-mirror() {
409
    arguments=(
410
411
        "--package-url[The package dependency url]:The package dependency url: "
        "--mirror-url[The mirror url]:The mirror url: "
412
413
414
415
    )
    _arguments $arguments && return
}

416
_swift_package_update() {
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
    arguments=(
    )
    _arguments $arguments && return
}

# Generates completions for swift test
#
# In the final compdef file, set the following file header:
#
#     #compdef _swift_test
#     local context state state_descr line
#     typeset -A opt_args
_swift_test() {
    arguments=(
        "-Xcc[Pass flag through to all C compiler invocations]:Pass flag through to all C compiler invocations: "
        "-Xswiftc[Pass flag through to all Swift compiler invocations]:Pass flag through to all Swift compiler invocations: "
        "-Xlinker[Pass flag through to all linker invocations]:Pass flag through to all linker invocations: "
        "-Xcxx[Pass flag through to all C++ compiler invocations]:Pass flag through to all C++ compiler invocations: "
        "(--configuration -c)"{--configuration,-c}"[Build with configuration (debug|release) ]: :{_values '' 'debug[build with DEBUG configuration]' 'release[build with RELEASE configuration]'}"
        "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
        "(--chdir -C)"{--chdir,-C}"[]: :_files"
        "--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
445
446
        "--version[]"
        "--destination[]: :_files"
        "(--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
450
451
452
453
454
        "--force-resolved-versions[]"
        "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
        "--enable-index-store[Enable indexing-while-building feature]"
        "--disable-index-store[Disable indexing-while-building feature]"
        "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
        "--enable-parseable-module-interfaces[]"
455
456
457
        "--trace-resolver[]"
        "(--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: "
        "--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
458
459
460
461
        "--skip-build[Skip building the test target]"
        "(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]"
        "--generate-linuxmain[Generate LinuxMain.swift entries for the package]"
        "--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
469
470
471
472
473
474
    )
    _arguments $arguments && return
}

_swift_compiler() {
}

_swift