Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 215 lines (202 sloc) 9.167 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
#compdef play
# ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Play! framework 1.2.2 (http://www.playframework.org).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Julien Nicoulaud <julien.nicoulaud@gmail.com>
# * Mario Fernandez (https://github.com/sirech)
#
# ------------------------------------------------------------------------------


_play() {
  local context curcontext="$curcontext" state line
  typeset -A opt_args

  local ret=1

  _arguments -C \
    '1: :_play_cmds' \
    '*::arg:->args' \
  && ret=0

  case $state in
    (args)
      curcontext="${curcontext%:*:*}:play-cmd-$words[1]:"
      case $line[1] in
        (build-module|list-modules|lm|check|id)
          _message 'no more arguments' && ret=0
        ;;
        (dependencies|deps)
          _arguments \
            '1:: :_play_apps' \
            '(--debug)--debug[Debug mode (even more informations logged than in verbose mode)]' \
            '(--jpda)--jpda[Listen for JPDA connection. The process will suspended until a client is plugged to the JPDA port.]' \
            '(--sync)--sync[Keep lib/ and modules/ directory synced. Delete unknow dependencies.]' \
            '(--verbose)--verbose[Verbose Mode]' \
          && ret=0
        ;;
        (clean|javadoc|jd|out|pid|secret|stop)
          _arguments '1:: :_play_apps' && ret=0
        ;;
        (help)
          _arguments '1: :_play_cmds -F "(cp deps ec idea jd st lm nb nm help antify evolutions evolutions:apply evolutions:markApplied evolutions:resolve)"' && ret=0
        ;;
        (status|st)
          _arguments \
            '1:: :_play_apps' \
            '(--url)--url[If you want to monitor an application running on a remote server, specify the application URL using this option]:URL:_urls' \
            '(--secret)--secret[You can provide your own secret key using this option]:Secret key' \
          && ret=0
        ;;
        (new)
          _arguments \
            '1: :_play_apps' \
            '(--with)--with[Automatically enable this set of module for the newly created application]:Modules list:_play_modules_list' \
          && ret=0
        ;;
        (install)
          _arguments '1:Play! module:_play_modules_dash_versions' && ret=0
        ;;
        (new-module)
          _arguments '1:Module directory:_files -/' && ret=0
        ;;
        (test|precompile|run|start|war|auto-test|classpath|cp|eclipsify|ec|idealize|idea|modules|netbeansify|nb)
          local cmd_args; cmd_args=(
            '1:: :_play_apps'
            '(--deps)--deps[Resolve and install dependencies before running the command]'
          )
          case $line[1] in
            (precompile|run|start|restart|war)
              local app_dir="$line[2]"
              [[ -d "$app_dir" ]] || app_dir=.
              [[ -f "$app_dir/conf/application.conf" ]] && cmd_args+=('--'${(u)${(M)$(<$app_dir/conf/application.conf):#%*}%%.*}'[Use this ID to run the application (override the default framework ID)]')
            ;|
            (test|run)
              cmd_args+=('(-f)-f[Disable the JPDA port checking and force the jpda.port value]')
            ;|
            (war)
              cmd_args+=(
                '(-o --output)'{-o,--output}'[The path where the WAR directory will be created. The contents of this directory will first be deleted]:output directory:_files -/'
                '(--zip)--zip[By default, the script creates an exploded WAR. If you want a zipped archive, specify the --zip option]'
                '(--exclude)--exclude[Excludes a list of colon separated directories]:excluded directories list:_play_colon_dirs_list'
              )
            ;|
            (test|run|start|restart|war)
              cmd_args+=('*:Java option')
            ;;
          esac
          _arguments "$cmd_args[@]" && ret=0
        ;;
        *)
          _call_function ret _play_cmd_$words[1] && ret=0
          (( ret )) && _message 'no more arguments'
        ;;
      esac
    ;;
  esac
}

# FIXME Completes only core commands, some modules add commands too (eg Maven). Where do we get them ?
# FIXME Parse 'play help' and 'play help <command>' (for aliases) instead of hard-coding.
(( $+functions[_play_cmds] )) ||
_play_cmds() {
  local commands; commands=(
    'antify:Create a build.xml file for this project'
    'auto-test:Automatically run all application tests'
    'build-module:Build and package a module'
    'check:Check for a release newer than the current one'
    {classpath,cp}':Display the computed classpath'
    'clean:Delete temporary files (including the bytecode cache)'
    {dependencies,deps}':Resolve and retrieve project dependencies'
    {eclipsify,ec}':Create all Eclipse configuration files'
    'evolutions:Run the evolution check'
    'evolutions\:apply:Automatically apply pending evolutions'
    'evolutions\:mark:AppliedMark pending evolutions as manually applied'
    'evolutions\:resolve:Resolve partially applied evolution'
    'help:Display help on a specific command'
    'id:Define the framework ID'
    {idealize,idea}':Create all IntelliJ Idea configuration files'
    'install:Install a module'
    {javadoc,jd}':Generate your application Javadoc'
    {list-modules,lm}':List modules available from the central modules repository'
    'modules:Display the computed modules list'
    {netbeansify,nb}':Create all NetBeans configuration files'
    'new:Create a new application'
    {new-module,nm}':Create a module'
    'out:Follow logs/system.out file'
    'pid:Show the PID of the running application'
    'precompile:Precompile all Java sources and templates to speed up application start-up'
    'restart:Restart the running application'
    'run:Run the application in the current shell'
    'secret:Generate a new secret key'
    'start:Start the application in the background'
    {status,st}':Display the running application status'
    'stop:Stop the running application'
    'test:Run the application in test mode in the current shell'
    'war:Export the application as a standalone WAR archive'
  )
  _describe -t commands 'Play! command' commands "$@"
}

(( $+functions[_play_apps] )) ||
_play_apps() {
  _wanted application expl 'Play! application directory' _files -/
}

(( $+functions[_play_modules] )) ||
_play_modules() {
  local modules; modules=(${(ps:,:)${${${(S)${(f)$(_call_program modules $service list-modules)}//\]*\[/,}%%\]*}##*\[}})
  _describe -t modules 'Play! module' modules "$@"
}

(( $+functions[_play_modules_dash_versions] )) ||
_play_modules_dash_versions() {
  local ret=1
  if compset -P '*-'; then
    local versions; versions=(${(ps:,:)${${${${${(f)$(_call_program versions $service list-modules)}##*${IPREFIX%-}\]}#*Versions:}%%"~"*}//[[:space:]]/}})
    _describe -t module-versions "${IPREFIX%-} module versions" versions && ret=0
  else
    _wanted modules expl 'Play! module' _play_modules -qS- && ret=0
  fi
}

(( $+functions[_play_modules_list] )) ||
_play_modules_list() {
  compset -P '*,'; compset -S ',*'
  _wanted module-list expl 'Play! modules list' _play_modules -qS,
}

(( $+functions[_play_colon_dirs_list] )) ||
_play_colon_dirs_list() {
  compset -P '*:'; compset -S ':*'
  _wanted directories-list expl 'Directories list' _files -/ -qS:
}

_play "$@"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et
Something went wrong with that request. Please try again.