From 9624ce992ec3482041c3086bc88f0485eb8d9bd3 Mon Sep 17 00:00:00 2001 From: Thi Date: Fri, 10 Aug 2018 02:10:32 +0900 Subject: Add shell completion for Swift Package Manager (#7046) This was generated by the Swift compiler 4.1.2 using the following command: swift package completion-tool generate-zsh-script --- plugins/swiftpm/_swift | 362 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 362 insertions(+) create mode 100644 plugins/swiftpm/_swift (limited to 'plugins/swiftpm') diff --git a/plugins/swiftpm/_swift b/plugins/swiftpm/_swift new file mode 100644 index 000000000..901b5d9e2 --- /dev/null +++ b/plugins/swiftpm/_swift @@ -0,0 +1,362 @@ +#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: . or ./]:Run test cases matching regular expression, Format: . or ./: " + ) + _arguments $arguments && return +} + +_swift_compiler() { +} + +_swift -- cgit v1.2.3-70-g09d2 From 7b29684a3087c881f240ebb74bd387c69f0ffcc6 Mon Sep 17 00:00:00 2001 From: Raul Ferreira Date: Sun, 7 Oct 2018 22:33:29 +0100 Subject: swiftpm: update swift completion script (#7243) --- plugins/swiftpm/_swift | 147 ++++++++++++++++++++++++++----------------------- 1 file changed, 79 insertions(+), 68 deletions(-) (limited to 'plugins/swiftpm') diff --git a/plugins/swiftpm/_swift b/plugins/swiftpm/_swift index 901b5d9e2..bed6e13a7 100644 --- a/plugins/swiftpm/_swift +++ b/plugins/swiftpm/_swift @@ -72,14 +72,16 @@ _swift_build() { "--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" + "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--disable-prefetching[]" + "--skip-update[Skip updating dependencies from their remote during a resolution]" "--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]" + "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--static-swift-stdlib[Link Swift stdlib statically]" - "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]" + "--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: " @@ -106,14 +108,16 @@ _swift_run() { "--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" + "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--disable-prefetching[]" + "--skip-update[Skip updating dependencies from their remote during a resolution]" "--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]" + "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--static-swift-stdlib[Link Swift stdlib statically]" - "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]" + "--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]" "--skip-build[Skip building the executable product]" ) _arguments $arguments && return @@ -136,14 +140,16 @@ _swift_package() { "--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" + "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--disable-prefetching[]" + "--skip-update[Skip updating dependencies from their remote during a resolution]" "--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]" + "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--static-swift-stdlib[Link Swift stdlib statically]" - "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]" + "--enable-build-manifest-caching[Enable llbuild manifest caching \[Experimental\]]" '(-): :->command' '(-)*:: :->arg' ) @@ -152,135 +158,133 @@ _swift_package() { (command) local modes modes=( + 'edit:Put a package in editable mode' + 'clean:Delete build artifacts' + 'init:Initialize a new package' + 'dump-package:Print parsed Package.swift as JSON' + 'describe:Describe the current package' + 'unedit:Remove a package from editable mode' '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' + 'resolve:Resolve package dependencies' 'generate-xcodeproj:Generates an Xcode project' - 'init:Initialize a new package' - 'dump-package:Print parsed Package.swift as JSON' + 'fetch:' + 'show-dependencies:Print the resolved dependency graph' ) _describe "mode" modes ;; (arg) case ${words[1]} in - (update) - _swift_package_update + (edit) + _swift_package_edit ;; - (show-dependencies) - _swift_package_show-dependencies + (clean) + _swift_package_clean ;; - (resolve) - _swift_package_resolve + (init) + _swift_package_init ;; - (fetch) - _swift_package_fetch + (dump-package) + _swift_package_dump-package + ;; + (describe) + _swift_package_describe + ;; + (unedit) + _swift_package_unedit + ;; + (update) + _swift_package_update ;; (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 + (resolve) + _swift_package_resolve ;; (generate-xcodeproj) _swift_package_generate-xcodeproj ;; - (init) - _swift_package_init + (fetch) + _swift_package_fetch ;; - (dump-package) - _swift_package_dump-package + (show-dependencies) + _swift_package_show-dependencies ;; esac ;; esac } -_swift_package_update() { +_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_show-dependencies() { +_swift_package_clean() { 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() { +_swift_package_init() { 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: " + "--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_fetch() { +_swift_package_dump-package() { arguments=( ) _arguments $arguments && return } -_swift_package_completion-tool() { +_swift_package_describe() { 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]'}" + "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}" ) _arguments $arguments && return } -_swift_package_edit() { +_swift_package_unedit() { 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" + ":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_tools-version() { +_swift_package_update() { 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() { +_swift_package_completion-tool() { arguments=( - "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}" + ": :{_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() { +_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 } @@ -291,10 +295,12 @@ _swift_package_reset() { _arguments $arguments && return } -_swift_package_unedit() { +_swift_package_resolve() { arguments=( - ":The name of the package to unedit:_swift_dependency" - "--force[Unedit the package even if it has uncommited and unpushed changes.]" + ":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 } @@ -304,19 +310,21 @@ _swift_package_generate-xcodeproj() { "--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]" ) _arguments $arguments && return } -_swift_package_init() { +_swift_package_fetch() { 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() { +_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 } @@ -338,19 +346,22 @@ _swift_test() { "--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" + "--sanitize[Turn on runtime checks for erroneous behavior]: :{_values '' 'address[enable Address sanitizer]' 'thread[enable Thread sanitizer]'}" "--disable-prefetching[]" + "--skip-update[Skip updating dependencies from their remote during a resolution]" "--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]" + "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--static-swift-stdlib[Link Swift stdlib statically]" - "--enable-build-manifest-caching[Enable llbuild manifest caching [Experimental]]" + "--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}"[]: : " + "--xunit-output[]: :_files" "--filter[Run test cases matching regular expression, Format: . or ./]:Run test cases matching regular expression, Format: . or ./: " ) _arguments $arguments && return -- cgit v1.2.3-70-g09d2 From 651856d4a3b37467cd26a5c5d8de52bd76a9be7f Mon Sep 17 00:00:00 2001 From: Roman Dzieciol Date: Sun, 7 Apr 2019 23:26:43 +0100 Subject: Update the swiftpm plugin autocompletion for Swift 5.0 --- plugins/swiftpm/README.md | 19 ++++ plugins/swiftpm/_swift | 235 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 183 insertions(+), 71 deletions(-) (limited to 'plugins/swiftpm') diff --git a/plugins/swiftpm/README.md b/plugins/swiftpm/README.md index 07ca25651..d9462fb7f 100644 --- a/plugins/swiftpm/README.md +++ b/plugins/swiftpm/README.md @@ -20,3 +20,22 @@ plugins=(... swiftpm) | `spx` | Generates an Xcode project | `swift package generate-xcodeproj` | | `sps` | Print the resolved dependency graph | `swift package show-dependencies` | | `spd` | Print parsed Package.swift as JSON | `swift package dump-package` | + +## Autocompletion + +The `_swift` file enables autocompletion for Swift Package Manager. Current version supports Swift 5.0 + + +### Updating the autocompletion for new version of Swift + +To update autocompletion to the Swift version present on your system: +``` +swift package completion-tool generate-zsh-script > ~/.oh-my-zsh/plugins/swiftpm/_swift +``` + +### Known issues + +If `swiftpm` is not added to your zsh plugins list, autocompletion will still be triggered but will result in errors: +``` +_values:compvalues:10: not enough arguments +``` diff --git a/plugins/swiftpm/_swift b/plugins/swiftpm/_swift index bed6e13a7..1366b4d9c 100644 --- a/plugins/swiftpm/_swift +++ b/plugins/swiftpm/_swift @@ -72,16 +72,23 @@ _swift_build() { "--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" - "--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[]" "--skip-update[Skip updating dependencies from their remote during a resolution]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]" + "--disable-package-manifest-caching[Disable caching Package.swift manifests]" "--version[]" "--destination[]: :_files" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--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]" "--product[Build the specified product]:Build the specified product: " "--target[Build the specified target]:Build the specified target: " @@ -108,17 +115,26 @@ _swift_run() { "--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" - "--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[]" "--skip-update[Skip updating dependencies from their remote during a resolution]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]" + "--disable-package-manifest-caching[Disable caching Package.swift manifests]" "--version[]" "--destination[]: :_files" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--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]" + "--build-tests[Build both source and test targets]" + "--repl[Launch Swift REPL for the package]" ) _arguments $arguments && return } @@ -140,16 +156,23 @@ _swift_package() { "--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" - "--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[]" "--skip-update[Skip updating dependencies from their remote during a resolution]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]" + "--disable-package-manifest-caching[Disable caching Package.swift manifests]" "--version[]" "--destination[]: :_files" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--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' '(-)*:: :->arg' ) @@ -158,91 +181,124 @@ _swift_package() { (command) local modes modes=( - 'edit:Put a package in editable mode' - 'clean:Delete build artifacts' - 'init:Initialize a new package' - 'dump-package:Print parsed Package.swift as JSON' + 'update:Update package dependencies' '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' - '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)' - 'tools-version:Manipulate tools version of the current package' - 'reset:Reset the complete cache/build directory' - 'resolve:Resolve package dependencies' + 'clean:Delete build artifacts' 'generate-xcodeproj:Generates an Xcode project' - 'fetch:' - 'show-dependencies:Print the resolved dependency graph' + 'reset:Reset the complete cache/build directory' + 'init:Initialize a new package' ) _describe "mode" modes ;; (arg) case ${words[1]} in - (edit) - _swift_package_edit - ;; - (clean) - _swift_package_clean - ;; - (init) - _swift_package_init - ;; - (dump-package) - _swift_package_dump-package + (update) + _swift_package_update ;; (describe) _swift_package_describe ;; + (resolve) + _swift_package_resolve + ;; + (tools-version) + _swift_package_tools-version + ;; (unedit) _swift_package_unedit ;; - (update) - _swift_package_update + (show-dependencies) + _swift_package_show-dependencies ;; - (completion-tool) - _swift_package_completion-tool + (fetch) + _swift_package_fetch ;; - (tools-version) - _swift_package_tools-version + (dump-package) + _swift_package_dump-package ;; - (reset) - _swift_package_reset + (edit) + _swift_package_edit ;; - (resolve) - _swift_package_resolve + (config) + _swift_package_config + ;; + (completion-tool) + _swift_package_completion-tool + ;; + (clean) + _swift_package_clean ;; (generate-xcodeproj) _swift_package_generate-xcodeproj ;; - (fetch) - _swift_package_fetch + (reset) + _swift_package_reset ;; - (show-dependencies) - _swift_package_show-dependencies + (init) + _swift_package_init ;; esac ;; esac } -_swift_package_edit() { +_swift_package_update() { 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_clean() { +_swift_package_describe() { arguments=( + "--type[json|text]: :{_values '' 'text[describe using text format]' 'json[describe using JSON format]'}" ) _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=( - "--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 } @@ -253,54 +309,80 @@ _swift_package_dump-package() { _arguments $arguments && return } -_swift_package_describe() { +_swift_package_edit() { 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 } -_swift_package_unedit() { +_swift_package_config() { arguments=( - ":The name of the package to unedit:_swift_dependency" - "--force[Unedit the package even if it has uncommited and unpushed changes.]" + '(-): :->command' + '(-)*:: :->arg' ) _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=( + "--package-url[The package dependency url]:The package dependency url: " + "--mirror-url[The mirror url]:The mirror url: " ) _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]'}" + "--package-url[The package dependency url]:The package dependency url: " + "--mirror-url[The mirror url]:The mirror url: " ) _arguments $arguments && return } -_swift_package_tools-version() { +_swift_package_config_get-mirror() { 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]" + "--package-url[The package dependency url]:The package dependency url: " ) _arguments $arguments && return } -_swift_package_reset() { +_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_resolve() { +_swift_package_clean() { 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 } @@ -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" "--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_fetch() { +_swift_package_reset() { arguments=( ) _arguments $arguments && return } -_swift_package_show-dependencies() { +_swift_package_init() { 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 } @@ -346,23 +430,32 @@ _swift_test() { "--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" - "--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[]" "--skip-update[Skip updating dependencies from their remote during a resolution]" "--disable-sandbox[Disable using the sandbox when executing subprocesses]" + "--disable-package-manifest-caching[Disable caching Package.swift manifests]" "--version[]" "--destination[]: :_files" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--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]" "(--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.]" + "--num-workers[Number of tests to execute in parallel.]:Number of tests to execute in parallel.: " "(--specifier -s)"{--specifier,-s}"[]: : " "--xunit-output[]: :_files" "--filter[Run test cases matching regular expression, Format: . or ./]:Run test cases matching regular expression, Format: . or ./: " + "--enable-code-coverage[Test with code coverage enabled]" ) _arguments $arguments && return } -- cgit v1.2.3-70-g09d2 From 2ec868dde4adaca55bfa3fdac3585cd92f2a34c1 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 8 Apr 2019 23:22:15 +0200 Subject: swiftpm: improve README --- plugins/swiftpm/README.md | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'plugins/swiftpm') diff --git a/plugins/swiftpm/README.md b/plugins/swiftpm/README.md index d9462fb7f..291458511 100644 --- a/plugins/swiftpm/README.md +++ b/plugins/swiftpm/README.md @@ -2,7 +2,7 @@ ## 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`: @@ -20,22 +20,3 @@ plugins=(... swiftpm) | `spx` | Generates an Xcode project | `swift package generate-xcodeproj` | | `sps` | Print the resolved dependency graph | `swift package show-dependencies` | | `spd` | Print parsed Package.swift as JSON | `swift package dump-package` | - -## Autocompletion - -The `_swift` file enables autocompletion for Swift Package Manager. Current version supports Swift 5.0 - - -### Updating the autocompletion for new version of Swift - -To update autocompletion to the Swift version present on your system: -``` -swift package completion-tool generate-zsh-script > ~/.oh-my-zsh/plugins/swiftpm/_swift -``` - -### Known issues - -If `swiftpm` is not added to your zsh plugins list, autocompletion will still be triggered but will result in errors: -``` -_values:compvalues:10: not enough arguments -``` -- cgit v1.2.3-70-g09d2