_swift 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. #compdef swift
  2. local context state state_descr line
  3. _swift_commandname=$words[1]
  4. typeset -A opt_args
  5. _swift() {
  6. integer ret=1
  7. local -a args
  8. args+=(
  9. '(-h --help)'{-h,--help}'[Show help information.]'
  10. '(-): :->command'
  11. '(-)*:: :->arg'
  12. )
  13. _arguments -w -s -S $args[@] && ret=0
  14. case $state in
  15. (command)
  16. local subcommands
  17. subcommands=(
  18. 'run:Build and run an executable product'
  19. 'build:Build sources into binary products'
  20. 'test:Build and run tests'
  21. 'package:Perform operations on Swift packages'
  22. 'help:Show subcommand help information.'
  23. )
  24. _describe "subcommand" subcommands
  25. ;;
  26. (arg)
  27. case ${words[1]} in
  28. (run)
  29. _swift_run
  30. ;;
  31. (build)
  32. _swift_build
  33. ;;
  34. (test)
  35. _swift_test
  36. ;;
  37. (package)
  38. _swift_package
  39. ;;
  40. (help)
  41. _swift_help
  42. ;;
  43. esac
  44. ;;
  45. esac
  46. return ret
  47. }
  48. _swift_run() {
  49. integer ret=1
  50. local -a args
  51. args+=(
  52. '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/'
  53. '--cache-path[Specify the shared cache directory path]:cache-path:_files -/'
  54. '--config-path[Specify the shared configuration directory path]:config-path:_files -/'
  55. '--security-path[Specify the shared security directory path]:security-path:_files -/'
  56. '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
  57. '--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
  58. specify more than one path.]:pkg-config-path:_files -/'
  59. '--enable-dependency-cache[Use a shared cache when fetching dependencies]'
  60. '--disable-dependency-cache[Use a shared cache when fetching dependencies]'
  61. '--enable-build-manifest-caching'
  62. '--disable-build-manifest-caching'
  63. '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
  64. '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
  65. '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
  66. '(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
  67. '--disable-sandbox[Disable using the sandbox when executing subprocesses]'
  68. '--netrc[Use netrc file even in cases where other credential stores are preferred]'
  69. '--enable-netrc[Load credentials from a netrc file]'
  70. '--disable-netrc[Load credentials from a netrc file]'
  71. '--netrc-file[Specify the netrc file path]:netrc-file:_files'
  72. '--enable-keychain[Search credentials in macOS keychain]'
  73. '--disable-keychain[Search credentials in macOS keychain]'
  74. '--resolver-fingerprint-checking:resolver-fingerprint-checking:'
  75. '--resolver-signing-entity-checking:resolver-signing-entity-checking:'
  76. '--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  77. '--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  78. '--enable-prefetching'
  79. '--disable-prefetching'
  80. '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
  81. '--skip-update[Skip updating dependencies from their remote during a resolution]'
  82. '--disable-scm-to-registry-transformation[disable source control to registry transformation]'
  83. '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
  84. '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
  85. '--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
  86. '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
  87. '-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
  88. '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
  89. '-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
  90. '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
  91. '--triple:triple:'
  92. '--sdk:sdk:_files -/'
  93. '--toolchain:toolchain:_files -/'
  94. '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
  95. '--auto-index-store[Enable or disable indexing-while-building feature]'
  96. '--enable-index-store[Enable or disable indexing-while-building feature]'
  97. '--disable-index-store[Enable or disable indexing-while-building feature]'
  98. '--enable-parseable-module-interfaces'
  99. '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
  100. '--emit-swift-module-separately'
  101. '--use-integrated-swift-driver'
  102. '--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
  103. '--experimental-explicit-module-build'
  104. '--build-system:build-system:(native xcode)'
  105. '--enable-dead-strip[Disable/enable dead code stripping by the linker]'
  106. '--disable-dead-strip[Disable/enable dead code stripping by the linker]'
  107. '--static-swift-stdlib[Link Swift stdlib statically]'
  108. '--no-static-swift-stdlib[Link Swift stdlib statically]'
  109. '--repl[Launch Swift REPL for the package]'
  110. '--debugger[Launch the executable in a debugger session]'
  111. '--run[Launch the executable with the provided arguments]'
  112. '--skip-build[Skip building the executable product]'
  113. '--build-tests[Build both source and test targets]'
  114. ':executable:{local -a list; list=(${(f)"$(swift package completion-tool list-executables)"}); _describe '''' list}'
  115. ':arguments:'
  116. '--version[Show the version.]'
  117. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  118. )
  119. _arguments -w -s -S $args[@] && ret=0
  120. return ret
  121. }
  122. _swift_build() {
  123. integer ret=1
  124. local -a args
  125. args+=(
  126. '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/'
  127. '--cache-path[Specify the shared cache directory path]:cache-path:_files -/'
  128. '--config-path[Specify the shared configuration directory path]:config-path:_files -/'
  129. '--security-path[Specify the shared security directory path]:security-path:_files -/'
  130. '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
  131. '--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
  132. specify more than one path.]:pkg-config-path:_files -/'
  133. '--enable-dependency-cache[Use a shared cache when fetching dependencies]'
  134. '--disable-dependency-cache[Use a shared cache when fetching dependencies]'
  135. '--enable-build-manifest-caching'
  136. '--disable-build-manifest-caching'
  137. '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
  138. '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
  139. '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
  140. '(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
  141. '--disable-sandbox[Disable using the sandbox when executing subprocesses]'
  142. '--netrc[Use netrc file even in cases where other credential stores are preferred]'
  143. '--enable-netrc[Load credentials from a netrc file]'
  144. '--disable-netrc[Load credentials from a netrc file]'
  145. '--netrc-file[Specify the netrc file path]:netrc-file:_files'
  146. '--enable-keychain[Search credentials in macOS keychain]'
  147. '--disable-keychain[Search credentials in macOS keychain]'
  148. '--resolver-fingerprint-checking:resolver-fingerprint-checking:'
  149. '--resolver-signing-entity-checking:resolver-signing-entity-checking:'
  150. '--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  151. '--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  152. '--enable-prefetching'
  153. '--disable-prefetching'
  154. '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
  155. '--skip-update[Skip updating dependencies from their remote during a resolution]'
  156. '--disable-scm-to-registry-transformation[disable source control to registry transformation]'
  157. '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
  158. '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
  159. '--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
  160. '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
  161. '-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
  162. '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
  163. '-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
  164. '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
  165. '--triple:triple:'
  166. '--sdk:sdk:_files -/'
  167. '--toolchain:toolchain:_files -/'
  168. '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
  169. '--auto-index-store[Enable or disable indexing-while-building feature]'
  170. '--enable-index-store[Enable or disable indexing-while-building feature]'
  171. '--disable-index-store[Enable or disable indexing-while-building feature]'
  172. '--enable-parseable-module-interfaces'
  173. '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
  174. '--emit-swift-module-separately'
  175. '--use-integrated-swift-driver'
  176. '--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
  177. '--experimental-explicit-module-build'
  178. '--build-system:build-system:(native xcode)'
  179. '--enable-dead-strip[Disable/enable dead code stripping by the linker]'
  180. '--disable-dead-strip[Disable/enable dead code stripping by the linker]'
  181. '--static-swift-stdlib[Link Swift stdlib statically]'
  182. '--no-static-swift-stdlib[Link Swift stdlib statically]'
  183. '--build-tests[Build both source and test targets]'
  184. '--show-bin-path[Print the binary output path]'
  185. '--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]'
  186. '--target[Build the specified target]:target:'
  187. '--product[Build the specified product]:product:'
  188. '--version[Show the version.]'
  189. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  190. )
  191. _arguments -w -s -S $args[@] && ret=0
  192. return ret
  193. }
  194. _swift_test() {
  195. integer ret=1
  196. local -a args
  197. args+=(
  198. '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/'
  199. '--cache-path[Specify the shared cache directory path]:cache-path:_files -/'
  200. '--config-path[Specify the shared configuration directory path]:config-path:_files -/'
  201. '--security-path[Specify the shared security directory path]:security-path:_files -/'
  202. '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
  203. '--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
  204. specify more than one path.]:pkg-config-path:_files -/'
  205. '--enable-dependency-cache[Use a shared cache when fetching dependencies]'
  206. '--disable-dependency-cache[Use a shared cache when fetching dependencies]'
  207. '--enable-build-manifest-caching'
  208. '--disable-build-manifest-caching'
  209. '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
  210. '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
  211. '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
  212. '(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
  213. '--disable-sandbox[Disable using the sandbox when executing subprocesses]'
  214. '--netrc[Use netrc file even in cases where other credential stores are preferred]'
  215. '--enable-netrc[Load credentials from a netrc file]'
  216. '--disable-netrc[Load credentials from a netrc file]'
  217. '--netrc-file[Specify the netrc file path]:netrc-file:_files'
  218. '--enable-keychain[Search credentials in macOS keychain]'
  219. '--disable-keychain[Search credentials in macOS keychain]'
  220. '--resolver-fingerprint-checking:resolver-fingerprint-checking:'
  221. '--resolver-signing-entity-checking:resolver-signing-entity-checking:'
  222. '--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  223. '--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  224. '--enable-prefetching'
  225. '--disable-prefetching'
  226. '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
  227. '--skip-update[Skip updating dependencies from their remote during a resolution]'
  228. '--disable-scm-to-registry-transformation[disable source control to registry transformation]'
  229. '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
  230. '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
  231. '--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
  232. '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
  233. '-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
  234. '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
  235. '-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
  236. '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
  237. '--triple:triple:'
  238. '--sdk:sdk:_files -/'
  239. '--toolchain:toolchain:_files -/'
  240. '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
  241. '--auto-index-store[Enable or disable indexing-while-building feature]'
  242. '--enable-index-store[Enable or disable indexing-while-building feature]'
  243. '--disable-index-store[Enable or disable indexing-while-building feature]'
  244. '--enable-parseable-module-interfaces'
  245. '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
  246. '--emit-swift-module-separately'
  247. '--use-integrated-swift-driver'
  248. '--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
  249. '--experimental-explicit-module-build'
  250. '--build-system:build-system:(native xcode)'
  251. '--enable-dead-strip[Disable/enable dead code stripping by the linker]'
  252. '--disable-dead-strip[Disable/enable dead code stripping by the linker]'
  253. '--static-swift-stdlib[Link Swift stdlib statically]'
  254. '--no-static-swift-stdlib[Link Swift stdlib statically]'
  255. '--skip-build[Skip building the test target]'
  256. '--test-product[Test the specified product.]:test-product:'
  257. '--parallel[Run the tests in parallel.]'
  258. '--num-workers[Number of tests to execute in parallel.]:num-workers:'
  259. '(--list-tests -l)'{--list-tests,-l}'[Lists test methods in specifier format]'
  260. '(--show-codecov-path --show-code-coverage-path --show-coverage-path)'{--show-codecov-path,--show-code-coverage-path,--show-coverage-path}'[Print the path of the exported code coverage JSON file]'
  261. '(-s --specifier)'{-s,--specifier}':specifier:'
  262. '--filter[Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>]:filter:'
  263. '--skip[Skip test cases matching regular expression, Example: --skip PerformanceTests]:skip:'
  264. '--xunit-output[Path where the xUnit xml file should be generated.]:xunit-output:_files -/'
  265. '--enable-testable-imports[Enable or disable testable imports. Enabled by default.]'
  266. '--disable-testable-imports[Enable or disable testable imports. Enabled by default.]'
  267. '--enable-code-coverage[Enable code coverage]'
  268. '--disable-code-coverage[Enable code coverage]'
  269. '--version[Show the version.]'
  270. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  271. '(-): :->command'
  272. '(-)*:: :->arg'
  273. )
  274. _arguments -w -s -S $args[@] && ret=0
  275. case $state in
  276. (command)
  277. local subcommands
  278. subcommands=(
  279. 'list:Lists test methods in specifier format'
  280. 'generate-linuxmain:Generate LinuxMain.swift (deprecated)'
  281. )
  282. _describe "subcommand" subcommands
  283. ;;
  284. (arg)
  285. case ${words[1]} in
  286. (list)
  287. _swift_test_list
  288. ;;
  289. (generate-linuxmain)
  290. _swift_test_generate-linuxmain
  291. ;;
  292. esac
  293. ;;
  294. esac
  295. return ret
  296. }
  297. _swift_test_list() {
  298. integer ret=1
  299. local -a args
  300. args+=(
  301. '--skip-build[Skip building the test target]'
  302. '--test-product[Test the specified product.]:test-product:'
  303. '--version[Show the version.]'
  304. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  305. )
  306. _arguments -w -s -S $args[@] && ret=0
  307. return ret
  308. }
  309. _swift_test_generate-linuxmain() {
  310. integer ret=1
  311. local -a args
  312. args+=(
  313. '--version[Show the version.]'
  314. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  315. )
  316. _arguments -w -s -S $args[@] && ret=0
  317. return ret
  318. }
  319. _swift_package() {
  320. integer ret=1
  321. local -a args
  322. args+=(
  323. '--package-path[Specify the package path to operate on (default current directory). This changes the working directory before any other operation]:package-path:_files -/'
  324. '--cache-path[Specify the shared cache directory path]:cache-path:_files -/'
  325. '--config-path[Specify the shared configuration directory path]:config-path:_files -/'
  326. '--security-path[Specify the shared security directory path]:security-path:_files -/'
  327. '--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
  328. '--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
  329. specify more than one path.]:pkg-config-path:_files -/'
  330. '--enable-dependency-cache[Use a shared cache when fetching dependencies]'
  331. '--disable-dependency-cache[Use a shared cache when fetching dependencies]'
  332. '--enable-build-manifest-caching'
  333. '--disable-build-manifest-caching'
  334. '--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
  335. '(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
  336. '(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
  337. '(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
  338. '--disable-sandbox[Disable using the sandbox when executing subprocesses]'
  339. '--netrc[Use netrc file even in cases where other credential stores are preferred]'
  340. '--enable-netrc[Load credentials from a netrc file]'
  341. '--disable-netrc[Load credentials from a netrc file]'
  342. '--netrc-file[Specify the netrc file path]:netrc-file:_files'
  343. '--enable-keychain[Search credentials in macOS keychain]'
  344. '--disable-keychain[Search credentials in macOS keychain]'
  345. '--resolver-fingerprint-checking:resolver-fingerprint-checking:'
  346. '--resolver-signing-entity-checking:resolver-signing-entity-checking:'
  347. '--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  348. '--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
  349. '--enable-prefetching'
  350. '--disable-prefetching'
  351. '(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
  352. '--skip-update[Skip updating dependencies from their remote during a resolution]'
  353. '--disable-scm-to-registry-transformation[disable source control to registry transformation]'
  354. '--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
  355. '--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
  356. '--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
  357. '(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
  358. '-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
  359. '-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
  360. '-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
  361. '-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
  362. '--triple:triple:'
  363. '--sdk:sdk:_files -/'
  364. '--toolchain:toolchain:_files -/'
  365. '--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
  366. '--auto-index-store[Enable or disable indexing-while-building feature]'
  367. '--enable-index-store[Enable or disable indexing-while-building feature]'
  368. '--disable-index-store[Enable or disable indexing-while-building feature]'
  369. '--enable-parseable-module-interfaces'
  370. '(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
  371. '--emit-swift-module-separately'
  372. '--use-integrated-swift-driver'
  373. '--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
  374. '--experimental-explicit-module-build'
  375. '--build-system:build-system:(native xcode)'
  376. '--enable-dead-strip[Disable/enable dead code stripping by the linker]'
  377. '--disable-dead-strip[Disable/enable dead code stripping by the linker]'
  378. '--static-swift-stdlib[Link Swift stdlib statically]'
  379. '--no-static-swift-stdlib[Link Swift stdlib statically]'
  380. '--version[Show the version.]'
  381. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  382. '(-): :->command'
  383. '(-)*:: :->arg'
  384. )
  385. _arguments -w -s -S $args[@] && ret=0
  386. case $state in
  387. (command)
  388. local subcommands
  389. subcommands=(
  390. 'clean:Delete build artifacts'
  391. 'purge-cache:Purge the global repository cache.'
  392. 'reset:Reset the complete cache/build directory'
  393. 'update:Update package dependencies'
  394. 'describe:Describe the current package'
  395. 'init:Initialize a new package'
  396. 'diagnose-api-breaking-changes:Diagnose API-breaking changes to Swift modules in a package'
  397. 'dump-symbol-graph:Dump Symbol Graph'
  398. 'dump-package:Print parsed Package.swift as JSON'
  399. 'edit:Put a package in editable mode'
  400. 'unedit:Remove a package from editable mode'
  401. 'config:Manipulate configuration of the package'
  402. 'resolve:Resolve package dependencies'
  403. 'show-dependencies:Print the resolved dependency graph'
  404. 'tools-version:Manipulate tools version of the current package'
  405. 'compute-checksum:Compute the checksum for a binary artifact.'
  406. 'archive-source:Create a source archive for the package'
  407. 'completion-tool:Completion tool (for shell completions)'
  408. 'plugin:Invoke a command plugin or perform other actions on command plugins'
  409. )
  410. _describe "subcommand" subcommands
  411. ;;
  412. (arg)
  413. case ${words[1]} in
  414. (clean)
  415. _swift_package_clean
  416. ;;
  417. (purge-cache)
  418. _swift_package_purge-cache
  419. ;;
  420. (reset)
  421. _swift_package_reset
  422. ;;
  423. (update)
  424. _swift_package_update
  425. ;;
  426. (describe)
  427. _swift_package_describe
  428. ;;
  429. (init)
  430. _swift_package_init
  431. ;;
  432. (diagnose-api-breaking-changes)
  433. _swift_package_diagnose-api-breaking-changes
  434. ;;
  435. (dump-symbol-graph)
  436. _swift_package_dump-symbol-graph
  437. ;;
  438. (dump-package)
  439. _swift_package_dump-package
  440. ;;
  441. (edit)
  442. _swift_package_edit
  443. ;;
  444. (unedit)
  445. _swift_package_unedit
  446. ;;
  447. (config)
  448. _swift_package_config
  449. ;;
  450. (resolve)
  451. _swift_package_resolve
  452. ;;
  453. (show-dependencies)
  454. _swift_package_show-dependencies
  455. ;;
  456. (tools-version)
  457. _swift_package_tools-version
  458. ;;
  459. (compute-checksum)
  460. _swift_package_compute-checksum
  461. ;;
  462. (archive-source)
  463. _swift_package_archive-source
  464. ;;
  465. (completion-tool)
  466. _swift_package_completion-tool
  467. ;;
  468. (plugin)
  469. _swift_package_plugin
  470. ;;
  471. esac
  472. ;;
  473. esac
  474. return ret
  475. }
  476. _swift_package_clean() {
  477. integer ret=1
  478. local -a args
  479. args+=(
  480. '--version[Show the version.]'
  481. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  482. )
  483. _arguments -w -s -S $args[@] && ret=0
  484. return ret
  485. }
  486. _swift_package_purge-cache() {
  487. integer ret=1
  488. local -a args
  489. args+=(
  490. '--version[Show the version.]'
  491. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  492. )
  493. _arguments -w -s -S $args[@] && ret=0
  494. return ret
  495. }
  496. _swift_package_reset() {
  497. integer ret=1
  498. local -a args
  499. args+=(
  500. '--version[Show the version.]'
  501. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  502. )
  503. _arguments -w -s -S $args[@] && ret=0
  504. return ret
  505. }
  506. _swift_package_update() {
  507. integer ret=1
  508. local -a args
  509. args+=(
  510. '(--dry-run -n)'{--dry-run,-n}'[Display the list of dependencies that can be updated]'
  511. ':packages:'
  512. '--version[Show the version.]'
  513. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  514. )
  515. _arguments -w -s -S $args[@] && ret=0
  516. return ret
  517. }
  518. _swift_package_describe() {
  519. integer ret=1
  520. local -a args
  521. args+=(
  522. '--type[json | text]:type:'
  523. '--version[Show the version.]'
  524. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  525. )
  526. _arguments -w -s -S $args[@] && ret=0
  527. return ret
  528. }
  529. _swift_package_init() {
  530. integer ret=1
  531. local -a args
  532. args+=(
  533. '--type[Package type:]:type:'
  534. '--name[Provide custom package name]:name:'
  535. '--version[Show the version.]'
  536. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  537. )
  538. _arguments -w -s -S $args[@] && ret=0
  539. return ret
  540. }
  541. _swift_package_diagnose-api-breaking-changes() {
  542. integer ret=1
  543. local -a args
  544. args+=(
  545. '--breakage-allowlist-path[The path to a text file containing breaking changes which should be ignored by the API comparison. Each ignored breaking change in the file should appear on its own line and contain the exact message to be ignored (e.g. '"'"'API breakage: func foo() has been removed'"'"').]:breakage-allowlist-path:_files -/'
  546. ':treeish:'
  547. '--products[One or more products to include in the API comparison. If present, only the specified products (and any targets specified using `--targets`) will be compared.]:products:'
  548. '--targets[One or more targets to include in the API comparison. If present, only the specified targets (and any products specified using `--products`) will be compared.]:targets:'
  549. '--baseline-dir[The path to a directory used to store API baseline files. If unspecified, a temporary directory will be used.]:baseline-dir:_files -/'
  550. '--regenerate-baseline[Regenerate the API baseline, even if an existing one is available.]'
  551. '--version[Show the version.]'
  552. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  553. )
  554. _arguments -w -s -S $args[@] && ret=0
  555. return ret
  556. }
  557. _swift_package_dump-symbol-graph() {
  558. integer ret=1
  559. local -a args
  560. args+=(
  561. '--pretty-print[Pretty-print the output JSON.]'
  562. '--skip-synthesized-members[Skip members inherited through classes or default implementations.]'
  563. '--minimum-access-level[Include symbols with this access level or more. Possible values: private | fileprivate | internal | public | open]:minimum-access-level:(private fileprivate internal public open)'
  564. '--skip-inherited-docs[Skip emitting doc comments for members inherited through classes or default implementations.]'
  565. '--include-spi-symbols[Add symbols with SPI information to the symbol graph.]'
  566. '--emit-extension-block-symbols[Emit extension block symbols for extensions to external types or directly associate members and conformances with the extended nominal.]'
  567. '--omit-extension-block-symbols[Emit extension block symbols for extensions to external types or directly associate members and conformances with the extended nominal.]'
  568. '--version[Show the version.]'
  569. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  570. )
  571. _arguments -w -s -S $args[@] && ret=0
  572. return ret
  573. }
  574. _swift_package_dump-package() {
  575. integer ret=1
  576. local -a args
  577. args+=(
  578. '--version[Show the version.]'
  579. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  580. )
  581. _arguments -w -s -S $args[@] && ret=0
  582. return ret
  583. }
  584. _swift_package_edit() {
  585. integer ret=1
  586. local -a args
  587. args+=(
  588. '--revision[The revision to edit]:revision:'
  589. '--branch[The branch to create]:branch:'
  590. '--path[Create or use the checkout at this path]:path:_files -/'
  591. ':package-name:'
  592. '--version[Show the version.]'
  593. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  594. )
  595. _arguments -w -s -S $args[@] && ret=0
  596. return ret
  597. }
  598. _swift_package_unedit() {
  599. integer ret=1
  600. local -a args
  601. args+=(
  602. '--force[Unedit the package even if it has uncommited and unpushed changes]'
  603. ':package-name:'
  604. '--version[Show the version.]'
  605. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  606. )
  607. _arguments -w -s -S $args[@] && ret=0
  608. return ret
  609. }
  610. _swift_package_config() {
  611. integer ret=1
  612. local -a args
  613. args+=(
  614. '--version[Show the version.]'
  615. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  616. '(-): :->command'
  617. '(-)*:: :->arg'
  618. )
  619. _arguments -w -s -S $args[@] && ret=0
  620. case $state in
  621. (command)
  622. local subcommands
  623. subcommands=(
  624. 'set-mirror:Set a mirror for a dependency'
  625. 'unset-mirror:Remove an existing mirror'
  626. 'get-mirror:Print mirror configuration for the given package dependency'
  627. )
  628. _describe "subcommand" subcommands
  629. ;;
  630. (arg)
  631. case ${words[1]} in
  632. (set-mirror)
  633. _swift_package_config_set-mirror
  634. ;;
  635. (unset-mirror)
  636. _swift_package_config_unset-mirror
  637. ;;
  638. (get-mirror)
  639. _swift_package_config_get-mirror
  640. ;;
  641. esac
  642. ;;
  643. esac
  644. return ret
  645. }
  646. _swift_package_config_set-mirror() {
  647. integer ret=1
  648. local -a args
  649. args+=(
  650. '--original[The original url or identity]:original:'
  651. '--mirror[The mirror url or identity]:mirror:'
  652. '--version[Show the version.]'
  653. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  654. )
  655. _arguments -w -s -S $args[@] && ret=0
  656. return ret
  657. }
  658. _swift_package_config_unset-mirror() {
  659. integer ret=1
  660. local -a args
  661. args+=(
  662. '--original[The original url or identity]:original:'
  663. '--mirror[The mirror url or identity]:mirror:'
  664. '--version[Show the version.]'
  665. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  666. )
  667. _arguments -w -s -S $args[@] && ret=0
  668. return ret
  669. }
  670. _swift_package_config_get-mirror() {
  671. integer ret=1
  672. local -a args
  673. args+=(
  674. '--original[The original url or identity]:original:'
  675. '--version[Show the version.]'
  676. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  677. )
  678. _arguments -w -s -S $args[@] && ret=0
  679. return ret
  680. }
  681. _swift_package_resolve() {
  682. integer ret=1
  683. local -a args
  684. args+=(
  685. '--version[The version to resolve at]:version:'
  686. '--branch[The branch to resolve at]:branch:'
  687. '--revision[The revision to resolve at]:revision:'
  688. ':package-name:'
  689. '--version[Show the version.]'
  690. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  691. )
  692. _arguments -w -s -S $args[@] && ret=0
  693. return ret
  694. }
  695. _swift_package_show-dependencies() {
  696. integer ret=1
  697. local -a args
  698. args+=(
  699. '--format[text | dot | json | flatlist]:format:'
  700. '(--output-path -o)'{--output-path,-o}'[The absolute or relative path to output the resolved dependency graph.]:output-path:_files -/'
  701. '--version[Show the version.]'
  702. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  703. )
  704. _arguments -w -s -S $args[@] && ret=0
  705. return ret
  706. }
  707. _swift_package_tools-version() {
  708. integer ret=1
  709. local -a args
  710. args+=(
  711. '--set-current[Set tools version of package to the current tools version in use]'
  712. '--set[Set tools version of package to the given value]:set:'
  713. '--version[Show the version.]'
  714. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  715. )
  716. _arguments -w -s -S $args[@] && ret=0
  717. return ret
  718. }
  719. _swift_package_compute-checksum() {
  720. integer ret=1
  721. local -a args
  722. args+=(
  723. ':path:_files -/'
  724. '--version[Show the version.]'
  725. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  726. )
  727. _arguments -w -s -S $args[@] && ret=0
  728. return ret
  729. }
  730. _swift_package_archive-source() {
  731. integer ret=1
  732. local -a args
  733. args+=(
  734. '(-o --output)'{-o,--output}'[The absolute or relative path for the generated source archive]:output:_files -/'
  735. '--version[Show the version.]'
  736. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  737. )
  738. _arguments -w -s -S $args[@] && ret=0
  739. return ret
  740. }
  741. _swift_package_completion-tool() {
  742. integer ret=1
  743. local -a args
  744. args+=(
  745. ':mode:(generate-bash-script generate-zsh-script generate-fish-script list-dependencies list-executables list-snippets)'
  746. '--version[Show the version.]'
  747. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  748. )
  749. _arguments -w -s -S $args[@] && ret=0
  750. return ret
  751. }
  752. _swift_package_plugin() {
  753. integer ret=1
  754. local -a args
  755. args+=(
  756. '--list[List the available command plugins]'
  757. '--allow-writing-to-package-directory[Allow the plugin to write to the package directory]'
  758. '--allow-writing-to-directory[Allow the plugin to write to an additional directory]:allow-writing-to-directory:'
  759. '--allow-network-connections:allow-network-connections:(none local all docker unixDomainSocket)'
  760. ':command:'
  761. ':arguments:'
  762. '--version[Show the version.]'
  763. '(-help -h --help)'{-help,-h,--help}'[Show help information.]'
  764. )
  765. _arguments -w -s -S $args[@] && ret=0
  766. return ret
  767. }
  768. _swift_help() {
  769. integer ret=1
  770. local -a args
  771. args+=(
  772. ':subcommands:'
  773. )
  774. _arguments -w -s -S $args[@] && ret=0
  775. return ret
  776. }
  777. _custom_completion() {
  778. local completions=("${(@f)$($*)}")
  779. _describe '' completions
  780. }
  781. _swift