diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-15 11:44:52 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-15 11:44:52 -0600 |
commit | db6b995aea42dcea890e5b32491b43fc6f43f94e (patch) | |
tree | c85870a6c4d7fc7ead523d4dc6efa71d35a5ab67 /plugins/gradle | |
parent | 0eda0079acef106b39da4aaeccf8754ffc48231d (diff) | |
parent | e46843685c1f337e1266a51c9cae1889c4ae9eba (diff) | |
download | zsh-db6b995aea42dcea890e5b32491b43fc6f43f94e.tar.gz zsh-db6b995aea42dcea890e5b32491b43fc6f43f94e.tar.bz2 zsh-db6b995aea42dcea890e5b32491b43fc6f43f94e.zip |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/gradle')
l--------- | plugins/gradle/_gradle | 1 | ||||
l--------- | plugins/gradle/_gradlew | 1 | ||||
-rw-r--r-- | plugins/gradle/gradle.plugin.zsh | 33 |
3 files changed, 33 insertions, 2 deletions
diff --git a/plugins/gradle/_gradle b/plugins/gradle/_gradle new file mode 120000 index 000000000..80723f2fc --- /dev/null +++ b/plugins/gradle/_gradle @@ -0,0 +1 @@ +gradle.plugin.zsh
\ No newline at end of file diff --git a/plugins/gradle/_gradlew b/plugins/gradle/_gradlew new file mode 120000 index 000000000..80723f2fc --- /dev/null +++ b/plugins/gradle/_gradlew @@ -0,0 +1 @@ +gradle.plugin.zsh
\ No newline at end of file diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index a908eaeaa..b2015a351 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -60,6 +60,35 @@ _gradle_does_task_list_need_generating () { [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache ]] } +############## +# Parse the tasks from `gradle(w) tasks --all` into .gradletasknamecache +# All lines in the output from gradle(w) that are between /^-+$/ and /^\s*$/ +# are considered to be tasks. If and when gradle adds support for listing tasks +# for programmatic parsing, this method can be deprecated. +############## +_gradle_parse_tasks () { + lines_might_be_tasks=false + task_name_buffer="" + while read -r line; do + if [[ $line =~ ^-+$ ]]; then + lines_might_be_tasks=true + # Empty buffer, because it contains items that are not tasks + task_name_buffer="" + elif [[ $line =~ ^\s*$ ]]; then + if [[ "$lines_might_be_tasks" = true ]]; then + # If a newline is found, send the buffer to .gradletasknamecache + while read -r task; do + echo $task | awk '/[a-zA-Z0-9:-]+/ {print $1}' + done <<< "$task_name_buffer" + # Empty buffer, because we are done with the tasks + task_name_buffer="" + fi + lines_might_be_tasks=false + elif [[ "$lines_might_be_tasks" = true ]]; then + task_name_buffer="${task_name_buffer}\n${line}" + fi + done <<< "$1" +} ############################################################################## # Discover the gradle tasks by running "gradle tasks --all" @@ -68,7 +97,7 @@ _gradle_tasks () { if [[ -f build.gradle ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then - gradle tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache + _gradle_parse_tasks "$(gradle tasks --all)" > .gradletasknamecache fi compadd -X "==== Gradle Tasks ====" $(cat .gradletasknamecache) fi @@ -78,7 +107,7 @@ _gradlew_tasks () { if [[ -f build.gradle ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then - ./gradlew tasks --all | awk '/[a-zA-Z0-9:-]* - / {print $1}' > .gradletasknamecache + _gradle_parse_tasks "$(./gradlew tasks --all)" > .gradletasknamecache fi compadd -X "==== Gradlew Tasks ====" $(cat .gradletasknamecache) fi |