.bash_completion.d/gradle
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 16 Oct 2013 19:48:29 +0300
changeset 644 5a6d6ad8e7f4
parent 643 9f5ece28cd08
child 645 51f6d81be3da
permissions -rw-r--r--
Add cli option handling for gradle bash-completion.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
643
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
# -*- mode: sh; sh-shell-file: bash -*-
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
_gradle()
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
{
644
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
     5
   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 \
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
     6
     -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 \
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
     7
     -q --quiet -r --properties -s --stacktrace -t --tasks -u --no-search-upward -v --version -x --exclude-task"
643
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
   local _help_cmds='dependencies dependencyInsight help projects properties tasks'
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
   local _java_cmds='assemble build buildDependents buildNeeded classes compileJava processResources clean cleanTest jar testClasses compileTestJava processTestResources javadoc check test uploadArchives'
644
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    10
   local _application_cmds='run startScripts installApp distZip distTar'
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    11
   local cur prev
643
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
   cur=${COMP_WORDS[COMP_CWORD]}
644
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    13
   [[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    14
   case "$prev" in
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    15
     -I|--init-script|-b|--build-file|-c|--settings-file|-e|--embedded)
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    16
       COMPREPLY=( $(compgen -f -- "$cur") )
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    17
       return ;;
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    18
     -g|--gradle-user-home|-p|--project-dir)
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    19
       COMPREPLY=( $(compgen -d -- "$cur") )
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    20
       return ;;
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    21
   esac
643
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
   # colonprefixes=${cur%"${cur##*:}"}
644
5a6d6ad8e7f4 Add cli option handling for gradle bash-completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 643
diff changeset
    23
   COMPREPLY=( $(compgen -W '$_opts $_help_cmds $_java_cmds $_application_cmds'  -- $cur) )
643
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
   # local i=${#COMPREPLY[*]}
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    25
   # while [ $((--i)) -ge 0 ]; do
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    26
   #    COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    27
   # done
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
   return 0
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
} &&
9f5ece28cd08 Add gradle completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    30
complete -F _gradle gradle