diff --git a/_gradle b/_gradle index 10efa24..294879b 100644 --- a/_gradle +++ b/_gradle @@ -142,6 +142,51 @@ __gradle-completion-init() { return 0 } +# Instead of printing all tasks for all subprojects, print only subprojects names to limit number of entries shown on the screen +# Once a single subproject is choosen - return its all available tasks. +__gradle-trim-tasks-to-subprojects() { + if [[ "$1" =~ ^(.+:.*) ]]; then + # do nothing if a subproject is already choosen + cat + else + awk -F '[[:alnum:]_]:' '{ + # Split entries into (subprojects names) AND (tasks accessible from root project) + if ($1 ~ /:/) { + # keep only subproject name (skip task name part) + c = split($1, arr, "\\\\:") + + if (c == 3) { + current = "\\:" arr[c-1] "\\:" + } else { + current = arr[c-1] "\\:" + } + # keep uniq names (it assumes that the input to this funtion is already sorted) + if (m == 0 || current != module[m-1]) { + module[m++] = current + } + module_task_line[mtl++] = $0 + } else { + # otherwise store the whole line with description + root_task_line[rtl++] = $0 + } + } END { + for(i=0; i 1) { + for(i=0; i 1) { + for(i=0; i