Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bash): clean COMPREPLY only when needed #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions gradle-completion.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
_gradle-compreply-clean() {
# Remove description ("[:space:]" and after) if only one possibility
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
COMPREPLY=( ${COMPREPLY[0]%% *} )
fi

}

__gradle-completion-print-timestamp() {
echo "$(($(gdate +'%s * 1000 + %-N / 1000000'))) - $1"
}
Expand Down Expand Up @@ -133,6 +141,7 @@ __gradle-long-options() {
--write-locks - Persists dependency resolution for locked configurations"

COMPREPLY=( $(compgen -W "$args" -- "$cur") )
_gradle-compreply-clean
}

__gradle-properties() {
Expand All @@ -154,6 +163,7 @@ __gradle-properties() {
-Dorg.gradle.warning.mode= - Set types of warnings to log (all summary none)
-Dorg.gradle.workers.max= - Set the number of workers Gradle is allowed to use"
COMPREPLY=( $(compgen -W "$args" -- "$cur") )
_gradle-compreply-clean
return 0
}

Expand Down Expand Up @@ -183,6 +193,7 @@ __gradle-short-options() {
-P - Sets a project property of the root project
-S - Print out the full (very verbose) stacktrace"
COMPREPLY=( $(compgen -W "$args" -- "$cur") )
_gradle-compreply-clean
}

__gradle-tasks() {
Expand All @@ -207,6 +218,7 @@ __gradle-tasks() {
cached_tasks=( $(grep "^$cur" "$cache_dir/$cached_checksum") )
fi
COMPREPLY=( $(compgen -W "${cached_tasks[*]}" -- "$cur") )
_gradle-compreply-clean
else
__gradle-notify-tasks-cache-build
fi
Expand All @@ -230,6 +242,7 @@ properties - Displays the properties of root project.
tasks - Displays the tasks runnable from root project.
wrapper - Generates Gradle wrapper files."
COMPREPLY=( $(compgen -W "$args" -- "$cur") )
_gradle-compreply-clean
fi

# Prevent colons from messing up completion
Expand Down Expand Up @@ -362,13 +375,9 @@ _gradle() {

IFS="$OLDIFS"

# Remove description ("[:space:]" and after) if only one possibility
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
COMPREPLY=( ${COMPREPLY[0]%% *} )
fi

return 0
}

complete -F _gradle gradle
complete -F _gradle gradle.bat
complete -F _gradle gradlew
Expand Down