123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- #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"
- "--disable-prefetching[]"
- "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
- "--version[]"
- "--destination[]: :_files"
- "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
- "--no-static-swift-stdlib[Do not link Swift stdlib statically]"
- "--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]"
- "--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"
- "--disable-prefetching[]"
- "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
- "--version[]"
- "--destination[]: :_files"
- "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
- "--no-static-swift-stdlib[Do not link Swift stdlib statically]"
- "--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]"
- "--skip-build[Skip building the executable product]"
- )
- _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"
- "--disable-prefetching[]"
- "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
- "--version[]"
- "--destination[]: :_files"
- "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
- "--no-static-swift-stdlib[Do not link Swift stdlib statically]"
- "--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]"
- '(-): :->command'
- '(-)*:: :->arg'
- )
- _arguments $arguments && return
- case $state in
- (command)
- local modes
- modes=(
- 'update:Update package dependencies'
- 'show-dependencies:Print the resolved dependency graph'
- 'resolve:Resolve package dependencies'
- 'fetch:'
- 'completion-tool:Completion tool (for shell completions)'
- 'edit:Put a package in editable mode'
- 'tools-version:Manipulate tools version of the current package'
- 'describe:Describe the current package'
- 'clean:Delete build artifacts'
- 'reset:Reset the complete cache/build directory'
- 'unedit:Remove a package from editable mode'
- 'generate-xcodeproj:Generates an Xcode project'
- 'init:Initialize a new package'
- 'dump-package:Print parsed Package.swift as JSON'
- )
- _describe "mode" modes
- ;;
- (arg)
- case ${words[1]} in
- (update)
- _swift_package_update
- ;;
- (show-dependencies)
- _swift_package_show-dependencies
- ;;
- (resolve)
- _swift_package_resolve
- ;;
- (fetch)
- _swift_package_fetch
- ;;
- (completion-tool)
- _swift_package_completion-tool
- ;;
- (edit)
- _swift_package_edit
- ;;
- (tools-version)
- _swift_package_tools-version
- ;;
- (describe)
- _swift_package_describe
- ;;
- (clean)
- _swift_package_clean
- ;;
- (reset)
- _swift_package_reset
- ;;
- (unedit)
- _swift_package_unedit
- ;;
- (generate-xcodeproj)
- _swift_package_generate-xcodeproj
- ;;
- (init)
- _swift_package_init
- ;;
- (dump-package)
- _swift_package_dump-package
- ;;
- esac
- ;;
- esac
- }
- _swift_package_update() {
- arguments=(
- )
- _arguments $arguments && return
- }
- _swift_package_show-dependencies() {
- arguments=(
- "--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_resolve() {
- arguments=(
- ":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_fetch() {
- arguments=(
- )
- _arguments $arguments && return
- }
- _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_edit() {
- arguments=(
- ":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"
- )
- _arguments $arguments && return
- }
- _swift_package_tools-version() {
- arguments=(
- "--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]"
- )
- _arguments $arguments && return
- }
- _swift_package_describe() {
- arguments=(
- "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
- )
- _arguments $arguments && return
- }
- _swift_package_clean() {
- arguments=(
- )
- _arguments $arguments && return
- }
- _swift_package_reset() {
- arguments=(
- )
- _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
- }
- _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"
- )
- _arguments $arguments && return
- }
- _swift_package_init() {
- arguments=(
- "--type[empty|library|executable|system-module]: :{_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]'}"
- )
- _arguments $arguments && return
- }
- _swift_package_dump-package() {
- 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"
- "--disable-prefetching[]"
- "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
- "--version[]"
- "--destination[]: :_files"
- "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
- "--no-static-swift-stdlib[Do not link Swift stdlib statically]"
- "--static-swift-stdlib[Link Swift stdlib statically]"
- "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]"
- "--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.]"
- "(--specifier -s)"{--specifier,-s}"[]: : "
- "--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>: "
- )
- _arguments $arguments && return
- }
- _swift_compiler() {
- }
- _swift
|