Add cli option handling for gradle bash-completion.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Wed, 16 Oct 2013 19:48:29 +0300
changeset 644 5a6d6ad8e7f4
parent 643 9f5ece28cd08
child 645 51f6d81be3da
Add cli option handling for gradle bash-completion.
.bash_completion.d/gradle
--- a/.bash_completion.d/gradle	Wed Oct 16 18:42:07 2013 +0300
+++ b/.bash_completion.d/gradle	Wed Oct 16 19:48:29 2013 +0300
@@ -2,13 +2,25 @@
 
 _gradle()
 {
-   local cmds cur colonprefixes
-   COMPREPLY=()
+   local _opts="-? -h --help -A --dep-tasks -C --cache -D --system-prop -I --init-script -P --project-prop -S --full-stacktrace -a --no-rebuild --all \
+     -b --build-file -c --settings-file -d --debug -e --embedded -g --gradle-user-home --gui -i --info -m --dry-run -n --dependencies --no-opt -p --project-dir \
+     -q --quiet -r --properties -s --stacktrace -t --tasks -u --no-search-upward -v --version -x --exclude-task"
    local _help_cmds='dependencies dependencyInsight help projects properties tasks'
    local _java_cmds='assemble build buildDependents buildNeeded classes compileJava processResources clean cleanTest jar testClasses compileTestJava processTestResources javadoc check test uploadArchives'
+   local _application_cmds='run startScripts installApp distZip distTar'
+   local cur prev
    cur=${COMP_WORDS[COMP_CWORD]}
+   [[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
+   case "$prev" in
+     -I|--init-script|-b|--build-file|-c|--settings-file|-e|--embedded)
+       COMPREPLY=( $(compgen -f -- "$cur") )
+       return ;;
+     -g|--gradle-user-home|-p|--project-dir)
+       COMPREPLY=( $(compgen -d -- "$cur") )
+       return ;;
+   esac
    # colonprefixes=${cur%"${cur##*:}"}
-   COMPREPLY=( $(compgen -W '$_help_cmds $_java_cmds'  -- $cur) )
+   COMPREPLY=( $(compgen -W '$_opts $_help_cmds $_java_cmds $_application_cmds'  -- $cur) )
    # local i=${#COMPREPLY[*]}
    # while [ $((--i)) -ge 0 ]; do
    #    COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}