.bash_completion.d/gradle
changeset 839 e22ea617339d
parent 835 b2e3e02b9259
child 840 92bd6fcf51da
equal deleted inserted replaced
838:98cdbead06be 839:e22ea617339d
     1 # -*- mode: sh; sh-shell-file: bash -*-
     1 # -*- mode: sh; sh-shell-file: bash -*-
       
     2 
       
     3 _gradle_cmd()
       
     4 {
       
     5   for ((i = $COMP_CWORD - 1; i > 0; i -= 1)); do
       
     6     case "${COMP_WORDS[i]}" in
       
     7       -*) continue ;;
       
     8       *" "*) continue ;;
       
     9     esac
       
    10     echo "${COMP_WORDS[i]}"
       
    11     return
       
    12   done
       
    13 }
     2 
    14 
     3 _gradle()
    15 _gradle()
     4 {
    16 {
     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 \
    17   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 \
     6      -b --build-file -c --settings-file -d --debug -e --embedded -g --gradle-user-home --gui -i --info -m --dry-run --no-opt -p --project-dir \
    18      -b --build-file -c --settings-file -d --debug -e --embedded -g --gradle-user-home --gui -i --info -m --dry-run --no-opt -p --project-dir \
     7      -q --quiet -r --properties -s --stacktrace -t --tasks -u --no-search-upward -v --version -x --exclude-task \
    19      -q --quiet -r --properties -s --stacktrace -t --tasks -u --no-search-upward -v --version -x --exclude-task \
     8      --continue --daemon --foreground --no-color --no-daemon --offline --parallel --parallel-threads --project-cache-dir --recompile-scripts --refresh --refresh-dependencies \
    20      --continue --daemon --foreground --no-color --no-daemon --offline --parallel --parallel-threads --project-cache-dir --recompile-scripts --refresh --refresh-dependencies \
     9      --rerun-tasks --stop"
    21      --rerun-tasks --stop"
    10   local _help_cmds='components dependencies dependencyInsight buildEnvironment help model projects properties tasks wrapper'
    22   local _help_cmds='components dependencies dependencyInsight buildEnvironment help model projects properties tasks wrapper'
    11   local _java_cmds='assemble build buildDependents buildNeeded classes compileJava processResources clean cleanTest jar testClasses compileTestJava processTestResources javadoc check test uploadArchives'
    23   local _java_cmds='assemble build buildDependents buildNeeded classes compileJava processResources cleanTest jar testClasses compileTestJava processTestResources javadoc check test uploadArchives'
    12   local _application_cmds='run startScripts installApp distZip distTar'
    24   local _application_cmds='run startScripts installApp distZip distTar'
    13   local _other_cmd='install interactive'
    25   local _other_cmd='clean init install interactive'
       
    26   declare -a _extra
    14   local cur prev
    27   local cur prev
    15   cur=${COMP_WORDS[COMP_CWORD]}
    28   cur=${COMP_WORDS[COMP_CWORD]}
    16   [[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
    29   [[ $COMP_CWORD != 0 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
    17   case "$prev" in
    30 
    18     -I|--init-script|-b|--build-file|-c|--settings-file|-e|--embedded)
    31   # Perform default option completion for command.
    19       COMPREPLY=( $(compgen -f -- "$cur") )
    32   if [[ -z "$curr" ]]; then
    20       return ;;
    33       case "$prev" in
    21     -g|--gradle-user-home|-p|--project-dir|--project-cache-dir)
    34         help)
    22       COMPREPLY=( $(compgen -d -- "$cur") )
    35           COMPREPLY=( --task )
    23       return ;;
    36           return ;;
       
    37         init)
       
    38           COMPREPLY=( --type )
       
    39           return ;;
       
    40         wrapper)
       
    41           COMPREPLY=( --gradle-version )
       
    42           return ;;
       
    43         dependencies)
       
    44           COMPREPLY=( --configuration )
       
    45           return ;;
       
    46       esac
       
    47   fi
       
    48 
       
    49   # Add or perform command specific completion.
       
    50   local cmd="$(_gradle_cmd)"
       
    51   case "$cmd" in
    24     help)
    52     help)
    25       COMPREPLY=( $(compgen -W "--task" -- "$cur") )
    53       case "$prev" in
    26       return ;;
    54         --task)
       
    55           COMPREPLY=( $(compgen -W '$_help_cmds $_java_cmds $_application_cmds $_other_cmd'  -- $cur) )
       
    56           return ;;
       
    57       esac
       
    58       _extra+=( --task )
       
    59       ;;
       
    60     init)
       
    61       case "$prev" in
       
    62         --type)
       
    63           COMPREPLY=( $(compgen -W "basic groovy-library java-library pom scala-library" -- "$cur") )
       
    64           return ;;
       
    65         --test-framework)
       
    66           COMPREPLY=( $(compgen -W "spock testng" -- "$cur") )
       
    67           return ;;
       
    68       esac
       
    69       _extra+=( --type --test-framework )
       
    70       ;;
    27     wrapper)
    71     wrapper)
    28       COMPREPLY=( $(compgen -W "--gradle-version" -- "$cur") )
    72       _extra+=( --gradle-version )
    29       return ;;
    73       ;;
    30     dependencies)
    74     dependencies)
    31       COMPREPLY=( $(compgen -W "--configuration" -- "$cur") )
    75       case "$prev" in
    32       return ;;
    76         --configuration)
    33     --configuration)
    77           local _configs="archives              - Configuration for archive artifacts.
    34       local _configs="archives              - Configuration for archive artifacts.
       
    35 compile               - Compile time dependencies.
    78 compile               - Compile time dependencies.
    36 compileClasspath      - Compile classpath, used when compiling source.
    79 compileClasspath      - Compile classpath, used when compiling source.
    37 compileOnly           - Compile time only dependencies, not used at runtime.
    80 compileOnly           - Compile time only dependencies, not used at runtime.
    38 default               - Dependencies required by this project at runtime.
    81 default               - Dependencies required by this project at runtime.
    39 optional              -
    82 optional              -
    41 runtime               - Runtime dependencies for source set 'main'.
    84 runtime               - Runtime dependencies for source set 'main'.
    42 testCompile           - Dependencies for source set 'test'.
    85 testCompile           - Dependencies for source set 'test'.
    43 testCompileClasspath  - Compile classpath for source set 'test'.
    86 testCompileClasspath  - Compile classpath for source set 'test'.
    44 testCompileOnly       - Compile dependencies for source set 'test'.
    87 testCompileOnly       - Compile dependencies for source set 'test'.
    45 testRuntime           - Runtime dependencies for source set 'test'."
    88 testRuntime           - Runtime dependencies for source set 'test'."
    46       local IFS=$'\n'
    89           local IFS=$'\n'
    47       COMPREPLY=( $(compgen -W '${_configs}' -- "$cur") )
    90           COMPREPLY=( $(compgen -W '${_configs}' -- "$cur") )
    48       if [[ ${#COMPREPLY[@]} -le 1 ]]; then
    91           if [[ ${#COMPREPLY[@]} -le 1 ]]; then
    49           COMPREPLY=( ${COMPREPLY[0]%% *-*} )
    92               COMPREPLY=( ${COMPREPLY[0]%% *-*} )
    50       fi
    93           fi
       
    94           return ;;
       
    95       esac
       
    96       _extra+=( --configuration )
       
    97       ;;
       
    98   esac
       
    99 
       
   100   # Perform generic completion.
       
   101   case "$prev" in
       
   102     -I|--init-script|-b|--build-file|-c|--settings-file|-e|--embedded)
       
   103       COMPREPLY=( $(compgen -f -- "$cur") )
    51       return ;;
   104       return ;;
    52     --task)
   105     -g|--gradle-user-home|-p|--project-dir|--project-cache-dir)
    53       COMPREPLY=( $(compgen -W '$_help_cmds $_java_cmds $_application_cmds $_other_cmd'  -- $cur) )
   106       COMPREPLY=( $(compgen -d -- "$cur") )
    54       return ;;
   107       return ;;
    55   esac
   108   esac
    56   # colonprefixes=${cur%"${cur##*:}"}
   109   COMPREPLY=( $(compgen -W '$_extra $_opts $_help_cmds $_java_cmds $_application_cmds $_other_cmd' -- $cur) )
    57   COMPREPLY=( $(compgen -W '$_opts $_help_cmds $_java_cmds $_application_cmds $_other_cmd'  -- $cur) )
   110   compopt +o nospace
    58   # local i=${#COMPREPLY[*]}
       
    59   # while [ $((--i)) -ge 0 ]; do
       
    60   #    COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
       
    61   # done
       
    62   return 0
       
    63 } &&
   111 } &&
    64     complete -F _gradle gradle ./gradlew
   112     complete -F _gradle gradle ./gradlew