Unverified Commit f12f7b03 authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

swiftpm: update autocompletion for Swift 5.0 (#7744)

parents 17057537 2ec868dd
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## Description ## Description
This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager). This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.0.
To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`: To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`:
......
...@@ -72,16 +72,23 @@ _swift_build() { ...@@ -72,16 +72,23 @@ _swift_build() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files" "(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]" "--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]" "--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]" "--version[]"
"--destination[]: :_files" "--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]" "--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--build-tests[Build both source and test targets]" "--build-tests[Build both source and test targets]"
"--product[Build the specified product]:Build the specified product: " "--product[Build the specified product]:Build the specified product: "
"--target[Build the specified target]:Build the specified target: " "--target[Build the specified target]:Build the specified target: "
...@@ -108,17 +115,26 @@ _swift_run() { ...@@ -108,17 +115,26 @@ _swift_run() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files" "(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]" "--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]" "--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]" "--version[]"
"--destination[]: :_files" "--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]" "--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--skip-build[Skip building the executable product]" "--skip-build[Skip building the executable product]"
"--build-tests[Build both source and test targets]"
"--repl[Launch Swift REPL for the package]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -140,16 +156,23 @@ _swift_package() { ...@@ -140,16 +156,23 @@ _swift_package() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files" "(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]" "--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]" "--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]" "--version[]"
"--destination[]: :_files" "--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]" "--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
'(-): :->command' '(-): :->command'
'(-)*:: :->arg' '(-)*:: :->arg'
) )
...@@ -158,91 +181,124 @@ _swift_package() { ...@@ -158,91 +181,124 @@ _swift_package() {
(command) (command)
local modes local modes
modes=( modes=(
'edit:Put a package in editable mode' 'update:Update package dependencies'
'clean:Delete build artifacts'
'init:Initialize a new package'
'dump-package:Print parsed Package.swift as JSON'
'describe:Describe the current package' 'describe:Describe the current package'
'resolve:Resolve package dependencies'
'tools-version:Manipulate tools version of the current package'
'unedit:Remove a package from editable mode' 'unedit:Remove a package from editable mode'
'update:Update package dependencies' 'show-dependencies:Print the resolved dependency graph'
'fetch:'
'dump-package:Print parsed Package.swift as JSON'
'edit:Put a package in editable mode'
'config:Manipulate configuration of the package'
'completion-tool:Completion tool (for shell completions)' 'completion-tool:Completion tool (for shell completions)'
'tools-version:Manipulate tools version of the current package' 'clean:Delete build artifacts'
'reset:Reset the complete cache/build directory'
'resolve:Resolve package dependencies'
'generate-xcodeproj:Generates an Xcode project' 'generate-xcodeproj:Generates an Xcode project'
'fetch:' 'reset:Reset the complete cache/build directory'
'show-dependencies:Print the resolved dependency graph' 'init:Initialize a new package'
) )
_describe "mode" modes _describe "mode" modes
;; ;;
(arg) (arg)
case ${words[1]} in case ${words[1]} in
(edit) (update)
_swift_package_edit _swift_package_update
;;
(clean)
_swift_package_clean
;;
(init)
_swift_package_init
;;
(dump-package)
_swift_package_dump-package
;; ;;
(describe) (describe)
_swift_package_describe _swift_package_describe
;; ;;
(resolve)
_swift_package_resolve
;;
(tools-version)
_swift_package_tools-version
;;
(unedit) (unedit)
_swift_package_unedit _swift_package_unedit
;; ;;
(update) (show-dependencies)
_swift_package_update _swift_package_show-dependencies
;; ;;
(completion-tool) (fetch)
_swift_package_completion-tool _swift_package_fetch
;; ;;
(tools-version) (dump-package)
_swift_package_tools-version _swift_package_dump-package
;; ;;
(reset) (edit)
_swift_package_reset _swift_package_edit
;; ;;
(resolve) (config)
_swift_package_resolve _swift_package_config
;;
(completion-tool)
_swift_package_completion-tool
;;
(clean)
_swift_package_clean
;; ;;
(generate-xcodeproj) (generate-xcodeproj)
_swift_package_generate-xcodeproj _swift_package_generate-xcodeproj
;; ;;
(fetch) (reset)
_swift_package_fetch _swift_package_reset
;; ;;
(show-dependencies) (init)
_swift_package_show-dependencies _swift_package_init
;; ;;
esac esac
;; ;;
esac esac
} }
_swift_package_edit() { _swift_package_update() {
arguments=( 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 _arguments $arguments && return
} }
_swift_package_clean() { _swift_package_describe() {
arguments=( arguments=(
"--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}"
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_init() { _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_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_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_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_fetch() {
arguments=( 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 _arguments $arguments && return
} }
...@@ -253,54 +309,80 @@ _swift_package_dump-package() { ...@@ -253,54 +309,80 @@ _swift_package_dump-package() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_describe() { _swift_package_edit() {
arguments=( arguments=(
"--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}" ":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 _arguments $arguments && return
} }
_swift_package_unedit() { _swift_package_config() {
arguments=( arguments=(
":The name of the package to unedit:_swift_dependency" '(-): :->command'
"--force[Unedit the package even if it has uncommited and unpushed changes.]" '(-)*:: :->arg'
) )
_arguments $arguments && return _arguments $arguments && return
case $state in
(command)
local modes
modes=(
'unset-mirror:Remove an existing mirror'
'set-mirror:Set a mirror for a dependency'
'get-mirror:Print mirror configuration for the given package dependency'
)
_describe "mode" modes
;;
(arg)
case ${words[1]} in
(unset-mirror)
_swift_package_config_unset-mirror
;;
(set-mirror)
_swift_package_config_set-mirror
;;
(get-mirror)
_swift_package_config_get-mirror
;;
esac
;;
esac
} }
_swift_package_update() { _swift_package_config_unset-mirror() {
arguments=( arguments=(
"--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_completion-tool() { _swift_package_config_set-mirror() {
arguments=( 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]'}" "--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_tools-version() { _swift_package_config_get-mirror() {
arguments=( arguments=(
"--set[Set tools version of package to the given value]:Set tools version of package to the given value: " "--package-url[The package dependency url]:The package dependency url: "
"--set-current[Set tools version of package to the current tools version in use]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_reset() { _swift_package_completion-tool() {
arguments=( 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 _arguments $arguments && return
} }
_swift_package_resolve() { _swift_package_clean() {
arguments=( 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 _arguments $arguments && return
} }
...@@ -312,19 +394,21 @@ _swift_package_generate-xcodeproj() { ...@@ -312,19 +394,21 @@ _swift_package_generate-xcodeproj() {
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files" "--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]" "--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]" "--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
"--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_fetch() { _swift_package_reset() {
arguments=( arguments=(
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_show-dependencies() { _swift_package_init() {
arguments=( 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]'}" "--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]'}"
"--name[Provide custom package name]:Provide custom package name: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -346,23 +430,32 @@ _swift_test() { ...@@ -346,23 +430,32 @@ _swift_test() {
"--build-path[Specify build/cache directory ]:Specify build/cache directory :_files" "--build-path[Specify build/cache directory ]:Specify build/cache directory :_files"
"(--chdir -C)"{--chdir,-C}"[]: :_files" "(--chdir -C)"{--chdir,-C}"[]: :_files"
"--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files" "--package-path[Change working directory before any other operation]:Change working directory before any other operation:_files"
"--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]' 'undefined[enable Undefined Behavior sanitizer]'}"
"--disable-prefetching[]" "--disable-prefetching[]"
"--skip-update[Skip updating dependencies from their remote during a resolution]" "--skip-update[Skip updating dependencies from their remote during a resolution]"
"--disable-sandbox[Disable using the sandbox when executing subprocesses]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]"
"--disable-package-manifest-caching[Disable caching Package.swift manifests]"
"--version[]" "--version[]"
"--destination[]: :_files" "--destination[]: :_files"
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]" "--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]"
"--skip-build[Skip building the test target]" "--skip-build[Skip building the test target]"
"(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]" "(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]"
"--generate-linuxmain[Generate LinuxMain.swift entries for the package]" "--generate-linuxmain[Generate LinuxMain.swift entries for the package]"
"--parallel[Run the tests in parallel.]" "--parallel[Run the tests in parallel.]"
"--num-workers[Number of tests to execute in parallel.]:Number of tests to execute in parallel.: "
"(--specifier -s)"{--specifier,-s}"[]: : " "(--specifier -s)"{--specifier,-s}"[]: : "
"--xunit-output[]: :_files" "--xunit-output[]: :_files"
"--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>: " "--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>: "
"--enable-code-coverage[Test with code coverage enabled]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment