You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/05/26 14:21:02 UTC

[2/3] groovy git commit: GROOVY-8605 Autocompletion for Groovy command line tools

GROOVY-8605 Autocompletion for Groovy command line tools


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/34d63691
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/34d63691
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/34d63691

Branch: refs/heads/master
Commit: 34d6369199ee28cbb3a972f3831da359215c0ad4
Parents: 95dfb2f
Author: Remko Popma <re...@yahoo.com>
Authored: Sat May 26 22:33:54 2018 +0900
Committer: Paul King <pa...@asert.com.au>
Committed: Sun May 27 00:18:00 2018 +1000

----------------------------------------------------------------------
 src/bin/grape_completion         | 181 ++++++++++++++++++++++++++++++++++
 src/bin/groovyConsole_completion | 106 ++++++++++++++++++++
 src/bin/groovy_completion        | 106 ++++++++++++++++++++
 src/bin/groovyc_completion       | 142 ++++++++++++++++++++++++++
 src/bin/groovydoc_completion     | 106 ++++++++++++++++++++
 src/bin/groovysh_completion      | 103 +++++++++++++++++++
 6 files changed, 744 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/34d63691/src/bin/grape_completion
----------------------------------------------------------------------
diff --git a/src/bin/grape_completion b/src/bin/grape_completion
new file mode 100644
index 0000000..1c59b0c
--- /dev/null
+++ b/src/bin/grape_completion
@@ -0,0 +1,181 @@
+#!/usr/bin/env bash
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+#
+# grape Bash Completion
+# =======================
+#
+# Bash completion support for the `grape` command,
+# generated by [picocli](http://picocli.info/) version 3.0.2.
+#
+# Installation
+# ------------
+#
+# 1. Source all completion scripts in your .bash_profile
+#
+#   cd $GROOVY_HOME/bin
+#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
+#
+# 2. Open a new bash console, and type `grape [TAB][TAB]`
+#
+# Documentation
+# -------------
+# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
+# 'grape (..)'. By reading entered command line parameters,
+# it determines possible bash completions and writes them to the COMPREPLY variable.
+# Bash then completes the user input if only one entry is listed in the variable or
+# shows the options if more than one is listed in COMPREPLY.
+#
+# References
+# ----------
+# [1] http://stackoverflow.com/a/12495480/1440785
+# [2] http://tiswww.case.edu/php/chet/bash/FAQ
+# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
+# [4] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
+# [5] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
+#
+
+# Enable programmable completion facilities (see [3])
+shopt -s progcomp
+
+# ArrContains takes two arguments, both of which are the name of arrays.
+# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
+# are in the hashtable.
+#
+# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
+# otherwise returns 1 (error).
+#
+# Modified from [4]
+function ArrContains() {
+  local lArr1 lArr2
+  declare -A tmp
+  eval lArr1=("\"\${$1[@]}\"")
+  eval lArr2=("\"\${$2[@]}\"")
+  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
+  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
+  return 0
+}
+
+# Bash completion entry point function.
+# _complete_grape finds which commands and subcommands have been specified
+# on the command line and delegates to the appropriate function
+# to generate possible options and subcommands for the last specified subcommand.
+function _complete_grape() {
+  CMDS0=(install)
+  CMDS1=(uninstall)
+  CMDS2=(list)
+  CMDS3=(resolve)
+  CMDS4=(help)
+
+  ArrContains COMP_WORDS CMDS4 && { _picocli_grape_help; return $?; }
+  ArrContains COMP_WORDS CMDS3 && { _picocli_grape_resolve; return $?; }
+  ArrContains COMP_WORDS CMDS2 && { _picocli_grape_list; return $?; }
+  ArrContains COMP_WORDS CMDS1 && { _picocli_grape_uninstall; return $?; }
+  ArrContains COMP_WORDS CMDS0 && { _picocli_grape_install; return $?; }
+
+  # No subcommands were specified; generate completions for the top-level command.
+  _picocli_grape; return $?;
+}
+
+# Generates completions for the options and subcommands of the `grape` command.
+function _picocli_grape() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS="install uninstall list resolve help"
+  FLAG_OPTS="-q --quiet -w --warn -i --info -V --verbose -d --debug -h --help -v --version"
+  ARG_OPTS="-D --define -r --resolver"
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Generates completions for the options and subcommands of the `install` subcommand.
+function _picocli_grape_install() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-h --help -v --version"
+  ARG_OPTS=""
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Generates completions for the options and subcommands of the `uninstall` subcommand.
+function _picocli_grape_uninstall() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-h --help -v --version"
+  ARG_OPTS=""
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Generates completions for the options and subcommands of the `list` subcommand.
+function _picocli_grape_list() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-h --help -v --version"
+  ARG_OPTS=""
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Generates completions for the options and subcommands of the `resolve` subcommand.
+function _picocli_grape_resolve() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-a --ant -d --dos -s --shell -i --ivy -h --help -v --version"
+  ARG_OPTS=""
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Generates completions for the options and subcommands of the `help` subcommand.
+function _picocli_grape_help() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-h --help"
+  ARG_OPTS=""
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Define a completion specification (a compspec) for the
+# `grape`, `grape.sh`, and `grape.bash` commands.
+# Uses the bash `complete` builtin (see [5]) to specify that shell function
+# `_complete_grape` is responsible for generating possible completions for the
+# current word on the command line.
+# The `-o default` option means that if the function generated no matches, the
+# default Bash completions and the Readline default filename completions are performed.
+complete -F _complete_grape -o default grape grape.sh grape.bash

http://git-wip-us.apache.org/repos/asf/groovy/blob/34d63691/src/bin/groovyConsole_completion
----------------------------------------------------------------------
diff --git a/src/bin/groovyConsole_completion b/src/bin/groovyConsole_completion
new file mode 100644
index 0000000..10c777c
--- /dev/null
+++ b/src/bin/groovyConsole_completion
@@ -0,0 +1,106 @@
+#!/usr/bin/env bash
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+#
+# groovyConsole Bash Completion
+# =======================
+#
+# Bash completion support for the `groovyConsole` command,
+# generated by [picocli](http://picocli.info/) version 3.0.2.
+#
+# Installation
+# ------------
+#
+# 1. Source all completion scripts in your .bash_profile
+#
+#   cd $GROOVY_HOME/bin
+#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
+#
+# 2. Open a new bash console, and type `groovyConsole [TAB][TAB]`
+#
+# Documentation
+# -------------
+# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
+# 'groovyConsole (..)'. By reading entered command line parameters,
+# it determines possible bash completions and writes them to the COMPREPLY variable.
+# Bash then completes the user input if only one entry is listed in the variable or
+# shows the options if more than one is listed in COMPREPLY.
+#
+# References
+# ----------
+# [1] http://stackoverflow.com/a/12495480/1440785
+# [2] http://tiswww.case.edu/php/chet/bash/FAQ
+# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
+# [4] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
+# [5] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
+#
+
+# Enable programmable completion facilities (see [3])
+shopt -s progcomp
+
+# ArrContains takes two arguments, both of which are the name of arrays.
+# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
+# are in the hashtable.
+#
+# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
+# otherwise returns 1 (error).
+#
+# Modified from [4]
+function ArrContains() {
+  local lArr1 lArr2
+  declare -A tmp
+  eval lArr1=("\"\${$1[@]}\"")
+  eval lArr2=("\"\${$2[@]}\"")
+  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
+  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
+  return 0
+}
+
+# Bash completion entry point function.
+# _complete_groovyConsole finds which commands and subcommands have been specified
+# on the command line and delegates to the appropriate function
+# to generate possible options and subcommands for the last specified subcommand.
+function _complete_groovyConsole() {
+
+
+  # No subcommands were specified; generate completions for the top-level command.
+  _picocli_groovyConsole; return $?;
+}
+
+# Generates completions for the options and subcommands of the `groovyConsole` command.
+function _picocli_groovyConsole() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-cp -classpath --classpath -h --help -V --version -pa --parameters -i --indy"
+  ARG_OPTS="-D --define --configscript"
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Define a completion specification (a compspec) for the
+# `groovyConsole`, `groovyConsole.sh`, and `groovyConsole.bash` commands.
+# Uses the bash `complete` builtin (see [5]) to specify that shell function
+# `_complete_groovyConsole` is responsible for generating possible completions for the
+# current word on the command line.
+# The `-o default` option means that if the function generated no matches, the
+# default Bash completions and the Readline default filename completions are performed.
+complete -F _complete_groovyConsole -o default groovyConsole groovyConsole.sh groovyConsole.bash

http://git-wip-us.apache.org/repos/asf/groovy/blob/34d63691/src/bin/groovy_completion
----------------------------------------------------------------------
diff --git a/src/bin/groovy_completion b/src/bin/groovy_completion
new file mode 100644
index 0000000..13cd712
--- /dev/null
+++ b/src/bin/groovy_completion
@@ -0,0 +1,106 @@
+#!/usr/bin/env bash
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+#
+# groovy Bash Completion
+# =======================
+#
+# Bash completion support for the `groovy` command,
+# generated by [picocli](http://picocli.info/) version 3.0.2.
+#
+# Installation
+# ------------
+#
+# 1. Source all completion scripts in your .bash_profile
+#
+#   cd $GROOVY_HOME/bin
+#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
+#
+# 2. Open a new bash console, and type `groovy [TAB][TAB]`
+#
+# Documentation
+# -------------
+# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
+# 'groovy (..)'. By reading entered command line parameters,
+# it determines possible bash completions and writes them to the COMPREPLY variable.
+# Bash then completes the user input if only one entry is listed in the variable or
+# shows the options if more than one is listed in COMPREPLY.
+#
+# References
+# ----------
+# [1] http://stackoverflow.com/a/12495480/1440785
+# [2] http://tiswww.case.edu/php/chet/bash/FAQ
+# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
+# [4] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
+# [5] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
+#
+
+# Enable programmable completion facilities (see [3])
+shopt -s progcomp
+
+# ArrContains takes two arguments, both of which are the name of arrays.
+# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
+# are in the hashtable.
+#
+# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
+# otherwise returns 1 (error).
+#
+# Modified from [4]
+function ArrContains() {
+  local lArr1 lArr2
+  declare -A tmp
+  eval lArr1=("\"\${$1[@]}\"")
+  eval lArr2=("\"\${$2[@]}\"")
+  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
+  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
+  return 0
+}
+
+# Bash completion entry point function.
+# _complete_groovy finds which commands and subcommands have been specified
+# on the command line and delegates to the appropriate function
+# to generate possible options and subcommands for the last specified subcommand.
+function _complete_groovy() {
+
+
+  # No subcommands were specified; generate completions for the top-level command.
+  _picocli_groovy; return $?;
+}
+
+# Generates completions for the options and subcommands of the `groovy` command.
+function _picocli_groovy() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-d --debug -n -p -pa --parameters --indy -h --help -v --version"
+  ARG_OPTS="-cp -classpath --classpath -D --define --disableopt -c --encoding -e -i -l -a --autosplit --configscript -b --basescript"
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Define a completion specification (a compspec) for the
+# `groovy`, `groovy.sh`, and `groovy.bash` commands.
+# Uses the bash `complete` builtin (see [5]) to specify that shell function
+# `_complete_groovy` is responsible for generating possible completions for the
+# current word on the command line.
+# The `-o default` option means that if the function generated no matches, the
+# default Bash completions and the Readline default filename completions are performed.
+complete -F _complete_groovy -o default groovy groovy.sh groovy.bash

http://git-wip-us.apache.org/repos/asf/groovy/blob/34d63691/src/bin/groovyc_completion
----------------------------------------------------------------------
diff --git a/src/bin/groovyc_completion b/src/bin/groovyc_completion
new file mode 100644
index 0000000..ebb2a2a
--- /dev/null
+++ b/src/bin/groovyc_completion
@@ -0,0 +1,142 @@
+#!/usr/bin/env bash
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+#
+# groovyc Bash Completion
+# =======================
+#
+# Bash completion support for the `groovyc` command,
+# generated by [picocli](http://picocli.info/) version 3.0.2.
+#
+# Installation
+# ------------
+#
+# 1. Source all completion scripts in your .bash_profile
+#
+#   cd $GROOVY_HOME/bin
+#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
+#
+# 2. Open a new bash console, and type `groovyc [TAB][TAB]`
+#
+# Documentation
+# -------------
+# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
+# 'groovyc (..)'. By reading entered command line parameters,
+# it determines possible bash completions and writes them to the COMPREPLY variable.
+# Bash then completes the user input if only one entry is listed in the variable or
+# shows the options if more than one is listed in COMPREPLY.
+#
+# References
+# ----------
+# [1] http://stackoverflow.com/a/12495480/1440785
+# [2] http://tiswww.case.edu/php/chet/bash/FAQ
+# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
+# [4] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
+# [5] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
+#
+
+# Enable programmable completion facilities (see [3])
+shopt -s progcomp
+
+# ArrContains takes two arguments, both of which are the name of arrays.
+# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
+# are in the hashtable.
+#
+# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
+# otherwise returns 1 (error).
+#
+# Modified from [4]
+function ArrContains() {
+  local lArr1 lArr2
+  declare -A tmp
+  eval lArr1=("\"\${$1[@]}\"")
+  eval lArr2=("\"\${$2[@]}\"")
+  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
+  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
+  return 0
+}
+
+# Bash completion entry point function.
+# _complete_groovyc finds which commands and subcommands have been specified
+# on the command line and delegates to the appropriate function
+# to generate possible options and subcommands for the last specified subcommand.
+function _complete_groovyc() {
+
+
+  # No subcommands were specified; generate completions for the top-level command.
+  _picocli_groovyc; return $?;
+}
+
+# Generates completions for the options and subcommands of the `groovyc` command.
+function _picocli_groovyc() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-e --exception -pa --parameters -j --jointCompilation --indy -h --help -v --version"
+  ARG_OPTS="-cp -classpath --classpath -sourcepath --sourcepath --temp --encoding -d -b --basescript -J -F --configscript"
+
+  case ${CURR_WORD} in
+    -sourcepath|--sourcepath)
+      compopt -o filenames
+      COMPREPLY=( $( compgen -f -- "" ) ) # files
+      return $?
+      ;;
+    --temp)
+      compopt -o filenames
+      COMPREPLY=( $( compgen -f -- "" ) ) # files
+      return $?
+      ;;
+    -d)
+      compopt -o filenames
+      COMPREPLY=( $( compgen -f -- "" ) ) # files
+      return $?
+      ;;
+    *)
+      case ${PREV_WORD} in
+        -sourcepath|--sourcepath)
+          compopt -o filenames
+          COMPREPLY=( $( compgen -f -- $CURR_WORD ) ) # files
+          return $?
+          ;;
+        --temp)
+          compopt -o filenames
+          COMPREPLY=( $( compgen -f -- $CURR_WORD ) ) # files
+          return $?
+          ;;
+        -d)
+          compopt -o filenames
+          COMPREPLY=( $( compgen -f -- $CURR_WORD ) ) # files
+          return $?
+          ;;
+      esac
+  esac
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Define a completion specification (a compspec) for the
+# `groovyc`, `groovyc.sh`, and `groovyc.bash` commands.
+# Uses the bash `complete` builtin (see [5]) to specify that shell function
+# `_complete_groovyc` is responsible for generating possible completions for the
+# current word on the command line.
+# The `-o default` option means that if the function generated no matches, the
+# default Bash completions and the Readline default filename completions are performed.
+complete -F _complete_groovyc -o default groovyc groovyc.sh groovyc.bash

http://git-wip-us.apache.org/repos/asf/groovy/blob/34d63691/src/bin/groovydoc_completion
----------------------------------------------------------------------
diff --git a/src/bin/groovydoc_completion b/src/bin/groovydoc_completion
new file mode 100644
index 0000000..afcdfc3
--- /dev/null
+++ b/src/bin/groovydoc_completion
@@ -0,0 +1,106 @@
+#!/usr/bin/env bash
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+#
+# groovydoc Bash Completion
+# =======================
+#
+# Bash completion support for the `groovydoc` command,
+# generated by [picocli](http://picocli.info/) version 3.0.2.
+#
+# Installation
+# ------------
+#
+# 1. Source all completion scripts in your .bash_profile
+#
+#   cd $GROOVY_HOME/bin
+#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
+#
+# 2. Open a new bash console, and type `groovydoc [TAB][TAB]`
+#
+# Documentation
+# -------------
+# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
+# 'groovydoc (..)'. By reading entered command line parameters,
+# it determines possible bash completions and writes them to the COMPREPLY variable.
+# Bash then completes the user input if only one entry is listed in the variable or
+# shows the options if more than one is listed in COMPREPLY.
+#
+# References
+# ----------
+# [1] http://stackoverflow.com/a/12495480/1440785
+# [2] http://tiswww.case.edu/php/chet/bash/FAQ
+# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
+# [4] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
+# [5] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
+#
+
+# Enable programmable completion facilities (see [3])
+shopt -s progcomp
+
+# ArrContains takes two arguments, both of which are the name of arrays.
+# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
+# are in the hashtable.
+#
+# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
+# otherwise returns 1 (error).
+#
+# Modified from [4]
+function ArrContains() {
+  local lArr1 lArr2
+  declare -A tmp
+  eval lArr1=("\"\${$1[@]}\"")
+  eval lArr2=("\"\${$2[@]}\"")
+  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
+  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
+  return 0
+}
+
+# Bash completion entry point function.
+# _complete_groovydoc finds which commands and subcommands have been specified
+# on the command line and delegates to the appropriate function
+# to generate possible options and subcommands for the last specified subcommand.
+function _complete_groovydoc() {
+
+
+  # No subcommands were specified; generate completions for the top-level command.
+  _picocli_groovydoc; return $?;
+}
+
+# Generates completions for the options and subcommands of the `groovydoc` command.
+function _picocli_groovydoc() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-h -help --help --version -verbose -quiet --debug -classpath -cp --classpath -author -noscripts -nomainforscripts -notimestamp -noversionstamp -public -protected -package -private"
+  ARG_OPTS="-d --destdir -overview -charset -fileEncoding -windowtitle -doctitle -header -footer -exclude -stylesheetfile -sourcepath"
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Define a completion specification (a compspec) for the
+# `groovydoc`, `groovydoc.sh`, and `groovydoc.bash` commands.
+# Uses the bash `complete` builtin (see [5]) to specify that shell function
+# `_complete_groovydoc` is responsible for generating possible completions for the
+# current word on the command line.
+# The `-o default` option means that if the function generated no matches, the
+# default Bash completions and the Readline default filename completions are performed.
+complete -F _complete_groovydoc -o default groovydoc groovydoc.sh groovydoc.bash

http://git-wip-us.apache.org/repos/asf/groovy/blob/34d63691/src/bin/groovysh_completion
----------------------------------------------------------------------
diff --git a/src/bin/groovysh_completion b/src/bin/groovysh_completion
new file mode 100644
index 0000000..5b8869c
--- /dev/null
+++ b/src/bin/groovysh_completion
@@ -0,0 +1,103 @@
+#!/usr/bin/env bash
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+#
+# groovysh Bash Completion
+# =======================
+#
+# Bash completion support for the `groovysh` command,
+# generated by [picocli](http://picocli.info/) version 3.0.2.
+#
+# 1. Source all completion scripts in your .bash_profile
+#
+#   cd $GROOVY_HOME/bin
+#   for f in $(find . -name "*_completion"); do line=". $(pwd)/$f"; grep "$line" ~/.bash_profile || echo "$line" >> ~/.bash_profile; done
+#
+# 2. Open a new bash console, and type `groovysh [TAB][TAB]`
+#
+# Documentation
+# -------------
+# The script is called by bash whenever [TAB] or [TAB][TAB] is pressed after
+# 'groovysh (..)'. By reading entered command line parameters,
+# it determines possible bash completions and writes them to the COMPREPLY variable.
+# Bash then completes the user input if only one entry is listed in the variable or
+# shows the options if more than one is listed in COMPREPLY.
+#
+# References
+# ----------
+# [1] http://stackoverflow.com/a/12495480/1440785
+# [2] http://tiswww.case.edu/php/chet/bash/FAQ
+# [3] https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
+# [4] https://stackoverflow.com/questions/17042057/bash-check-element-in-array-for-elements-in-another-array/17042655#17042655
+# [5] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion
+#
+
+# Enable programmable completion facilities (see [3])
+shopt -s progcomp
+
+# ArrContains takes two arguments, both of which are the name of arrays.
+# It creates a temporary hash from lArr1 and then checks if all elements of lArr2
+# are in the hashtable.
+#
+# Returns zero (no error) if all elements of the 2nd array are in the 1st array,
+# otherwise returns 1 (error).
+#
+# Modified from [4]
+function ArrContains() {
+  local lArr1 lArr2
+  declare -A tmp
+  eval lArr1=("\"\${$1[@]}\"")
+  eval lArr2=("\"\${$2[@]}\"")
+  for i in "${lArr1[@]}";{ [ -n "$i" ] && ((++tmp[$i]));}
+  for i in "${lArr2[@]}";{ [ -n "$i" ] && [ -z "${tmp[$i]}" ] && return 1;}
+  return 0
+}
+
+# Bash completion entry point function.
+# _complete_groovysh finds which commands and subcommands have been specified
+# on the command line and delegates to the appropriate function
+# to generate possible options and subcommands for the last specified subcommand.
+function _complete_groovysh() {
+
+
+  # No subcommands were specified; generate completions for the top-level command.
+  _picocli_groovysh; return $?;
+}
+
+# Generates completions for the options and subcommands of the `groovysh` command.
+function _picocli_groovysh() {
+  # Get completion data
+  CURR_WORD=${COMP_WORDS[COMP_CWORD]}
+  PREV_WORD=${COMP_WORDS[COMP_CWORD-1]}
+
+  COMMANDS=""
+  FLAG_OPTS="-cp -classpath --classpath -h --help -V --version -v --verbose -q --quiet -d --debug -pa --parameters"
+  ARG_OPTS="-e --evaluate -C --color -D --define -T --terminal"
+
+  COMPREPLY=( $(compgen -W "${FLAG_OPTS} ${ARG_OPTS} ${COMMANDS}" -- ${CURR_WORD}) )
+}
+
+# Define a completion specification (a compspec) for the
+# `groovysh`, `groovysh.sh`, and `groovysh.bash` commands.
+# Uses the bash `complete` builtin (see [5]) to specify that shell function
+# `_complete_groovysh` is responsible for generating possible completions for the
+# current word on the command line.
+# The `-o default` option means that if the function generated no matches, the
+# default Bash completions and the Readline default filename completions are performed.
+complete -F _complete_groovysh -o default groovysh groovysh.sh groovysh.bash