Class: Wagn::Commands::RakeCommand::Parser

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/wagn/commands/rake_command/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(command, opts) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/wagn/commands/rake_command/parser.rb', line 8

def initialize command, opts
  super() do |parser|
    parser.banner = "Usage: wagn #{command} [options]\n\n" \
                  "Run wagn:#{command} task on the production "\
                  " database specified in config/database.yml\n\n"
    parser.on("--production", "-p",
              "#{command} production database (default)") do
      opts[:envs] = ["production"]
    end
    parser.on("--test", "-t",
              "#{command} test database") do
      opts[:envs] = ["test"]
    end
    parser.on("--development", "-d",
              "#{command} development database") do
      opts[:envs] = ["development"]
    end
    parser.on("--all", "-a",
              "#{command} production, test, and development database") do
      opts[:envs] = %w(production development test)
    end
  end
end