Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix gradlew completion
- X-seq: zsh-workers 52170
- From: Shohei YOSHIDA <syohex@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Shohei YOSHIDA <syohex@xxxxxxxxx>
- Subject: [PATCH] Fix gradlew completion
- Date: Fri, 22 Sep 2023 11:50:03 +0900
- Archived-at: <https://zsh.org/workers/52170>
- List-id: <zsh-workers.zsh.org>
gradlew is not usually in the PATH so the command to retrieve tasks would fail
due to 'command not found'. So it should execute './gradlew' instead of 'gradle'
if service is gradlew and there is an executable file './gradlew' in current
directory
---
 Completion/Unix/Command/_gradle | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_gradle b/Completion/Unix/Command/_gradle
index c1f7c05ee..734429288 100644
--- a/Completion/Unix/Command/_gradle
+++ b/Completion/Unix/Command/_gradle
@@ -91,8 +91,13 @@ if [[ $state == task && ! -prefix - ]]; then
             if _cache_invalid $cache_name || ! _retrieve_cache $cache_name; then
                 zle -R "Generating cache from $gradle_buildfile"
 
+                local gradle_command=$service
+                if [[ $service == gradlew && -x ./gradlew ]]; then
+                    gradle_command='./gradlew'
+                fi
+
                 # Run gradle/gradlew and retrieve possible tasks.
-                for outputline in ${(f)"$($service --build-file $gradle_buildfile -q tasks --all)"}; do
+                for outputline in ${(f)"$($gradle_command --build-file $gradle_buildfile -q tasks --all)"}; do
 
                     # Tasks and subprojects each start with a lowercase letter, but whereas tasks are in camelCase, each
                     # subproject consists of one or more sections of kebab-case, with each section ending in a ':'.
-- 
2.39.2
Messages sorted by:
Reverse Date,
Date,
Thread,
Author