Class: OpsWorker::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/ops_worker/cli.rb

Class Method Summary collapse

Class Method Details

.startObject



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
# File 'lib/ops_worker/cli.rb', line 5

def self.start
  client = OpsWorker::Client.new

  sub_commands = ["deploy", "rollback", "update_cookbooks", "execute_recipe", "restart"]
  opts = Trollop::options do
    banner "ops_worker AWS OpsWorks helper"
    opt :app, "Application", :type => :string, :short => :a, :required => true
    stop_on sub_commands
  end

  command = ARGV.shift()

  app = client.find_app_by_name(opts[:app])

  case command
    when "deploy"
      command_opts = Trollop::options do
        opt :branch, "Branch", :type => :string
      end
      app.deploy(command_opts[:branch])
    when "rollback"
      app.rollback()
    when "update_cookbooks"
      app.update_cookbooks()
    when "execute_recipe"
      command_opts = Trollop::options do
        opt :recipe_name, "Recipe name", :type => :string, :required => true
      end
      app.execute_recipes([command_opts[:recipe_name]])
    when "restart"
      app.restart()
    else
      Trollop::die("Unknown command #{command}")
  end
end