Class: CloudFormula::CLI

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

Class Method Summary collapse

Class Method Details

.run(args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cloudformula/cli.rb', line 6

def self.run(args)
  parse_opts = parse_options args
  subcommand = parse_opts[:subcommand]
  opts = parse_opts[:opts]

  template = CloudFormula.template opts[:template], parse_parameters(opts[:parameters])

  begin
    case subcommand
      when 'generate'
        puts template.generate
      when 'create'
        stack = CloudFormula.create_stack opts[:region], opts[:'stack-name'], template
        puts stack.inspect
      when 'update'
        CloudFormula.update_stack opts[:region], opts[:'stack-name'], template
    end
  rescue Exception => e
    puts "ERROR: #{e.message}\n\nStack trace:\n#{e.backtrace.join("\n    from ")}"
  end
end