_swift 37 KB

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