_rails 1.75 KB
Newer Older
Tobias Preuss's avatar
Tobias Preuss committed
1
2
3
4
5
6
7
8
9
10
11
12
#compdef rails
#autoload

local -a _1st_arguments
_1st_arguments=(
    'generate:Generate new code (short-cut alias: "g")'
    'console:Start the Rails console (short-cut alias: "c")'
    'server:Start the Rails server (short-cut alias: "s")'
    'dbconsole:Start a console for the database specified in config/database.yml (short-cut alias: "db")'
    'new:Create a new Rails application. "rails new my_app" creates a new application called MyApp in "./my_app"'
    'application:Generate the Rails application code'
    'destroy:Undo code generated with "generate"'
13

Tobias Preuss's avatar
Tobias Preuss committed
14
15
16
    'benchmarker:See how fast a piece of code runs'
    'profiler:Get profile information from a piece of code'
    'plugin:Install a plugin'
17
18
19

    'plugin new:Generates skeleton for developing a Rails plugin'
    'runner:Run a piece of code in the application environment (short-cut alias: "r")'
Tobias Preuss's avatar
Tobias Preuss committed
20
21
22
23
)

_rails_generate_arguments() {
    generate_arguments=(
24
        assets
Tobias Preuss's avatar
Tobias Preuss committed
25
        controller
26
        decorator
Tobias Preuss's avatar
Tobias Preuss committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
        generator
        helper
        integration_test
        mailer
        migration
        model
        observer
        performance_test
        plugin
        resource
        scaffold
        scaffold_controller
        session_migration
        stylesheets
41
        task
Tobias Preuss's avatar
Tobias Preuss committed
42
43
44
    )
}

45

Tobias Preuss's avatar
Tobias Preuss committed
46
47
48
49
50
51
52
53
_arguments \
    '(--version)--version[show version]' \
    '(--help)--help[show help]' \
    '*:: :->subcmds' && return 0

if (( CURRENT == 1 )); then
  _describe -t commands "rails subcommand" _1st_arguments
  return
54
55
56
else
  _files
  return
Tobias Preuss's avatar
Tobias Preuss committed
57
58
59
fi

case "$words[1]" in
60
61
62
63
  g|generate)
    _rails_generate_arguments
    _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
  d|destroy)
Tobias Preuss's avatar
Tobias Preuss committed
64
65
66
    _rails_generate_arguments
    _wanted generate_arguments expl 'all generate' compadd -a generate_arguments ;;
esac