Class: SimpleDeploy::CLI::Create

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/simple_deploy/cli/create.rb

Instance Method Summary collapse

Methods included from Shared

#command_name, #parse_attributes, #rescue_stackster_exceptions_and_exit, #valid_options?

Instance Method Details

#command_summaryObject



51
52
53
# File 'lib/simple_deploy/cli/create.rb', line 51

def command_summary
  'Create a new stack'
end

#createObject



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
# File 'lib/simple_deploy/cli/create.rb', line 9

def create
  @opts = Trollop::options do
    version SimpleDeploy::VERSION
    banner "\nCreate a new stack.\n\nsimple_deploy create -n STACK_NAME -t PATH_TO_TEMPLATE -e ENVIRONMENT -a KEY1=VAL1 -a KEY2=VAL2\n\n"
    opt :help, "Display Help"
    opt :attributes, "= seperated attribute and it's value", :type  => :string,
                                                             :multi => true
    opt :environment, "Set the target environment", :type => :string
    opt :log_level, "Log level:  debug, info, warn, error", :type    => :string,
                                                            :default => 'info'
    opt :name, "Stack name(s) of stack to deploy", :type => :string
    opt :template, "Path to the template file", :type => :string
  end

  valid_options? :provided => @opts,
                 :required => [:environment, :name, :template]

  config = Config.new.environment @opts[:environment]

  attributes = parse_attributes :attributes => @opts[:attributes]

  stack = Stack.new :environment => @opts[:environment],
                    :name        => @opts[:name],
                    :config      => config,
                    :logger      => logger

  rescue_stackster_exceptions_and_exit do
    stack.create :attributes => attributes,
                 :template   => @opts[:template]
  end
end

#loggerObject



47
48
49
# File 'lib/simple_deploy/cli/create.rb', line 47

def logger
  @logger ||= SimpleDeployLogger.new :log_level => @opts[:log_level]
end