Class: Cody::CLI::Delete

Inherits:
Object
  • Object
show all
Includes:
AwsServices
Defined in:
lib/cody/cli/delete.rb

Instance Method Summary collapse

Methods included from AwsServices

#cfn, #codebuild

Methods included from AwsServices::Helpers

#are_you_sure?, #find_stack, #inferred_project_name, #inferred_stack_name, #normalize_stack_name, #project_name_convention, #stack_exists?

Constructor Details

#initialize(options) ⇒ Delete

Returns a new instance of Delete.



5
6
7
8
9
# File 'lib/cody/cli/delete.rb', line 5

def initialize(options)
  @options = options
  @project_name = options[:project_name] || inferred_project_name
  @stack_name = normalize_stack_name(options[:stack_name] || inferred_stack_name(@project_name))
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cody/cli/delete.rb', line 11

def run
  message = "Deleted #{@stack_name} stack."
  if @options[:noop]
    puts "NOOP #{message}"
  else
    are_you_sure?(@stack_name, :delete)

    if stack_exists?(@stack_name)
      cfn.delete_stack(stack_name: @stack_name)
      puts message
    else
      puts "#{@stack_name.inspect} stack does not exist".color(:red)
    end
  end
end