Commit 40df67bc authored by Tim's avatar Tim Committed by Marc Cornellà
Browse files

swiftpm: update completion for Swift 5.1 (#8248)

parent 534ec60b
...@@ -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), as well as autocompletion for Swift 5.0. 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.1.
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`:
......
...@@ -82,13 +82,15 @@ _swift_build() { ...@@ -82,13 +82,15 @@ _swift_build() {
"(--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-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--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: "
...@@ -125,13 +127,15 @@ _swift_run() { ...@@ -125,13 +127,15 @@ _swift_run() {
"(--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-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the executable product]" "--skip-build[Skip building the executable product]"
"--build-tests[Build both source and test targets]" "--build-tests[Build both source and test targets]"
"--repl[Launch Swift REPL for the package]" "--repl[Launch Swift REPL for the package]"
...@@ -166,13 +170,15 @@ _swift_package() { ...@@ -166,13 +170,15 @@ _swift_package() {
"(--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-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
'(-): :->command' '(-): :->command'
'(-)*:: :->arg' '(-)*:: :->arg'
) )
...@@ -181,49 +187,61 @@ _swift_package() { ...@@ -181,49 +187,61 @@ _swift_package() {
(command) (command)
local modes local modes
modes=( modes=(
'update:Update package dependencies' 'completion-tool:Completion tool (for shell completions)'
'dump-package:Print parsed Package.swift as JSON'
'describe:Describe the current package' 'describe:Describe the current package'
'resolve:Resolve package dependencies' 'clean:Delete build artifacts'
'tools-version:Manipulate tools version of the current package'
'unedit:Remove a package from editable mode'
'show-dependencies:Print the resolved dependency graph' 'show-dependencies:Print the resolved dependency graph'
'init:Initialize a new package'
'unedit:Remove a package from editable mode'
'tools-version:Manipulate tools version of the current package'
'fetch:' 'fetch:'
'dump-package:Print parsed Package.swift as JSON' 'resolve:Resolve package dependencies'
'reset:Reset the complete cache/build directory'
'generate-xcodeproj:Generates an Xcode project'
'edit:Put a package in editable mode' 'edit:Put a package in editable mode'
'config:Manipulate configuration of the package' 'config:Manipulate configuration of the package'
'completion-tool:Completion tool (for shell completions)' 'update:Update package dependencies'
'clean:Delete build artifacts'
'generate-xcodeproj:Generates an Xcode project'
'reset:Reset the complete cache/build directory'
'init:Initialize a new package'
) )
_describe "mode" modes _describe "mode" modes
;; ;;
(arg) (arg)
case ${words[1]} in case ${words[1]} in
(update) (completion-tool)
_swift_package_update _swift_package_completion-tool
;;
(dump-package)
_swift_package_dump-package
;; ;;
(describe) (describe)
_swift_package_describe _swift_package_describe
;; ;;
(resolve) (clean)
_swift_package_resolve _swift_package_clean
;; ;;
(tools-version) (show-dependencies)
_swift_package_tools-version _swift_package_show-dependencies
;;
(init)
_swift_package_init
;; ;;
(unedit) (unedit)
_swift_package_unedit _swift_package_unedit
;; ;;
(show-dependencies) (tools-version)
_swift_package_show-dependencies _swift_package_tools-version
;; ;;
(fetch) (fetch)
_swift_package_fetch _swift_package_fetch
;; ;;
(dump-package) (resolve)
_swift_package_dump-package _swift_package_resolve
;;
(reset)
_swift_package_reset
;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;; ;;
(edit) (edit)
_swift_package_edit _swift_package_edit
...@@ -231,27 +249,22 @@ _swift_package() { ...@@ -231,27 +249,22 @@ _swift_package() {
(config) (config)
_swift_package_config _swift_package_config
;; ;;
(completion-tool) (update)
_swift_package_completion-tool _swift_package_update
;;
(clean)
_swift_package_clean
;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;;
(reset)
_swift_package_reset
;;
(init)
_swift_package_init
;; ;;
esac esac
;; ;;
esac esac
} }
_swift_package_update() { _swift_package_completion-tool() {
arguments=(
": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
)
_arguments $arguments && return
}
_swift_package_dump-package() {
arguments=( arguments=(
) )
_arguments $arguments && return _arguments $arguments && return
...@@ -264,20 +277,23 @@ _swift_package_describe() { ...@@ -264,20 +277,23 @@ _swift_package_describe() {
_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
} }
_swift_package_tools-version() { _swift_package_show-dependencies() {
arguments=( arguments=(
"--set[Set tools version of package to the given value]:Set tools version of package to the given value: " "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
"--set-current[Set tools version of package to the current tools version in use]" )
_arguments $arguments && return
}
_swift_package_init() {
arguments=(
"--type[empty|library|executable|system-module|manifest]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
"--name[Provide custom package name]:Provide custom package name: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -290,9 +306,10 @@ _swift_package_unedit() { ...@@ -290,9 +306,10 @@ _swift_package_unedit() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_show-dependencies() { _swift_package_tools-version() {
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]'}" "--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 _arguments $arguments && return
} }
...@@ -303,8 +320,30 @@ _swift_package_fetch() { ...@@ -303,8 +320,30 @@ _swift_package_fetch() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_dump-package() { _swift_package_resolve() {
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
}
_swift_package_reset() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_generate-xcodeproj() {
arguments=(
"--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
"--enable-code-coverage[Enable code coverage in the generated project]"
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
"--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -330,8 +369,8 @@ _swift_package_config() { ...@@ -330,8 +369,8 @@ _swift_package_config() {
local modes local modes
modes=( modes=(
'unset-mirror:Remove an existing mirror' 'unset-mirror:Remove an existing mirror'
'set-mirror:Set a mirror for a dependency'
'get-mirror:Print mirror configuration for the given package dependency' 'get-mirror:Print mirror configuration for the given package dependency'
'set-mirror:Set a mirror for a dependency'
) )
_describe "mode" modes _describe "mode" modes
;; ;;
...@@ -340,12 +379,12 @@ _swift_package_config() { ...@@ -340,12 +379,12 @@ _swift_package_config() {
(unset-mirror) (unset-mirror)
_swift_package_config_unset-mirror _swift_package_config_unset-mirror
;; ;;
(set-mirror)
_swift_package_config_set-mirror
;;
(get-mirror) (get-mirror)
_swift_package_config_get-mirror _swift_package_config_get-mirror
;; ;;
(set-mirror)
_swift_package_config_set-mirror
;;
esac esac
;; ;;
esac esac
...@@ -359,14 +398,6 @@ _swift_package_config_unset-mirror() { ...@@ -359,14 +398,6 @@ _swift_package_config_unset-mirror() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_config_set-mirror() {
arguments=(
"--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
)
_arguments $arguments && return
}
_swift_package_config_get-mirror() { _swift_package_config_get-mirror() {
arguments=( arguments=(
"--package-url[The package dependency url]:The package dependency url: " "--package-url[The package dependency url]:The package dependency url: "
...@@ -374,41 +405,16 @@ _swift_package_config_get-mirror() { ...@@ -374,41 +405,16 @@ _swift_package_config_get-mirror() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_completion-tool() { _swift_package_config_set-mirror() {
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_clean() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_generate-xcodeproj() {
arguments=(
"--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
"--enable-code-coverage[Enable code coverage in the generated project]"
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
"--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
)
_arguments $arguments && return
}
_swift_package_reset() {
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_init() { _swift_package_update() {
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]'}"
"--name[Provide custom package name]:Provide custom package name: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -440,13 +446,15 @@ _swift_test() { ...@@ -440,13 +446,15 @@ _swift_test() {
"(--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-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--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]"
......
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