.bash_completion.d/gradle
changeset 841 84ce0f420480
parent 840 92bd6fcf51da
child 842 4ab3110d3c9d
equal deleted inserted replaced
840:92bd6fcf51da 841:84ce0f420480
     1 # -*- mode: sh; sh-shell-file: bash -*-
     1 # -*- mode: sh; sh-shell-file: bash -*-
     2 
     2 
     3 _gradle_cmd()
     3 _gradle_cmd()
     4 {
     4 {
     5   for ((i = $COMP_CWORD - 1; i > 0; i -= 1)); do
     5   for ((i = 1; i < $COMP_CWORD; i += 1)); do
     6     case "${COMP_WORDS[i]}" in
     6     case "${COMP_WORDS[i]}" in
     7       -*) continue ;;
     7       -*) continue ;;
     8       *" "*) continue ;;
     8       *" "*) continue ;;
     9     esac
     9     esac
    10     echo "${COMP_WORDS[i]}"
    10     echo "${COMP_WORDS[i]}"
    39           COMPREPLY=( --type )
    39           COMPREPLY=( --type )
    40           return ;;
    40           return ;;
    41         wrapper)
    41         wrapper)
    42           COMPREPLY=( --gradle-version )
    42           COMPREPLY=( --gradle-version )
    43           return ;;
    43           return ;;
    44         dependencies)
    44         dependencies|dependencyInsight)
    45           COMPREPLY=( --configuration )
    45           COMPREPLY=( --configuration )
    46           return ;;
    46           return ;;
    47       esac
    47       esac
    48   fi
    48   fi
    49 
    49 
       
    50   local _configs="archives              - Configuration for archive artifacts.
       
    51 compile               - Compile time dependencies.
       
    52 compileClasspath      - Compile classpath, used when compiling source.
       
    53 compileOnly           - Compile time only dependencies, not used at runtime.
       
    54 default               - Dependencies required by this project at runtime.
       
    55 optional              -
       
    56 provided              -
       
    57 runtime               - Runtime dependencies for source set 'main'.
       
    58 testCompile           - Dependencies for source set 'test'.
       
    59 testCompileClasspath  - Compile classpath for source set 'test'.
       
    60 testCompileOnly       - Compile dependencies for source set 'test'.
       
    61 testRuntime           - Runtime dependencies for source set 'test'."
       
    62 
    50   # Add or perform command specific completion.
    63   # Add or perform command specific completion.
    51   local cmd="$(_gradle_cmd)"
    64   local _cmd=$(_gradle_cmd)
    52   case "$cmd" in
    65   case "$_cmd" in
    53     help)
    66     help)
    54       case "$prev" in
    67       case "$prev" in
    55         --task)
    68         --task)
    56           COMPREPLY=( $(compgen -W '$_help_cmds $_java_cmds $_application_cmds $_other_cmd'  -- $cur) )
    69           COMPREPLY=( $(compgen -W '$_help_cmds $_java_cmds $_application_cmds $_other_cmd'  -- $cur) )
    57           return ;;
    70           return ;;
    73       _extra+=( --gradle-version )
    86       _extra+=( --gradle-version )
    74       ;;
    87       ;;
    75     dependencies)
    88     dependencies)
    76       case "$prev" in
    89       case "$prev" in
    77         --configuration)
    90         --configuration)
    78           local _configs="archives              - Configuration for archive artifacts.
       
    79 compile               - Compile time dependencies.
       
    80 compileClasspath      - Compile classpath, used when compiling source.
       
    81 compileOnly           - Compile time only dependencies, not used at runtime.
       
    82 default               - Dependencies required by this project at runtime.
       
    83 optional              -
       
    84 provided              -
       
    85 runtime               - Runtime dependencies for source set 'main'.
       
    86 testCompile           - Dependencies for source set 'test'.
       
    87 testCompileClasspath  - Compile classpath for source set 'test'.
       
    88 testCompileOnly       - Compile dependencies for source set 'test'.
       
    89 testRuntime           - Runtime dependencies for source set 'test'."
       
    90           local IFS=$'\n'
    91           local IFS=$'\n'
    91           COMPREPLY=( $(compgen -W '${_configs}' -- "$cur") )
    92           COMPREPLY=( $(compgen -W '${_configs}' -- "$cur") )
    92           if [[ ${#COMPREPLY[@]} -le 1 ]]; then
    93           if [[ ${#COMPREPLY[@]} -le 1 ]]; then
    93               COMPREPLY=( ${COMPREPLY[0]%% *-*} )
    94               COMPREPLY=( ${COMPREPLY[0]%% *-*} )
    94           fi
    95           fi
    95           return ;;
    96           return ;;
    96       esac
    97       esac
    97       _extra+=( --configuration )
    98       _extra+=( --configuration )
       
    99       ;;
       
   100     dependencyInsight)
       
   101       case "$prev" in
       
   102         --configuration)
       
   103           local IFS=$'\n'
       
   104           COMPREPLY=( $(compgen -W '${_configs}' -- "$cur") )
       
   105           if [[ ${#COMPREPLY[@]} -le 1 ]]; then
       
   106               COMPREPLY=( ${COMPREPLY[0]%% *-*} )
       
   107           fi
       
   108           return ;;
       
   109       esac
       
   110       _extra+=( --configuration --dependency )
    98       ;;
   111       ;;
    99   esac
   112   esac
   100 
   113 
   101   # Perform generic completion.
   114   # Perform generic completion.
   102   case "$prev" in
   115   case "$prev" in
   105       return ;;
   118       return ;;
   106     -g|--gradle-user-home|-p|--project-dir|--project-cache-dir)
   119     -g|--gradle-user-home|-p|--project-dir|--project-cache-dir)
   107       COMPREPLY=( $(compgen -d -- "$cur") )
   120       COMPREPLY=( $(compgen -d -- "$cur") )
   108       return ;;
   121       return ;;
   109   esac
   122   esac
   110   COMPREPLY=( $(compgen -W '$_extra $_opts $_help_cmds $_java_cmds $_application_cmds $_other_cmd' -- $cur) )
   123   COMPREPLY=( $(compgen -W '${_extra[@]} $_opts $_help_cmds $_java_cmds $_application_cmds $_other_cmd' -- $cur) )
   111   compopt +o nospace
   124   compopt +o nospace
   112 } &&
   125 } &&
   113     complete -F _gradle gradle ./gradlew
   126     complete -F _gradle gradle ./gradlew