zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Fix gradlew completion
@ 2023-09-22  2:50 Shohei YOSHIDA
  2023-09-22 23:36 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Shohei YOSHIDA @ 2023-09-22  2:50 UTC (permalink / raw)
  To: zsh-workers; +Cc: Shohei YOSHIDA

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-23  3:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-22  2:50 [PATCH] Fix gradlew completion Shohei YOSHIDA
2023-09-22 23:36 ` Oliver Kiddle
2023-09-23  3:13   ` Shohei Yoshida

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).