Class: Humidifier::Reservoir::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/humidifier/reservoir/cli.rb

Overview

A CLI for running commands to manipulate the stacks that Reservoir knows about.

Instance Method Summary collapse

Instance Method Details

#change(name = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/humidifier/reservoir/cli.rb', line 13

def change(name = nil)
  stack_names = stack_names_from(name)
  authorize

  stack_names.each do |stack_name|
    stack = Stack.new(stack_name)
    puts "Creating a changeset for #{stack.stack_name}"
    stack.create_change_set
  end
end

#deploy(name = nil, *parameters) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/humidifier/reservoir/cli.rb', line 28

def deploy(name = nil, *parameters)
  stack_names = stack_names_from(name)
  authorize

  stack_names.each do |stack_name|
    stack = Stack.new(stack_name, prefix: options[:prefix])
    puts "Deploying #{stack.stack_name}"
    stack.deploy(options[:wait], parameters_from(parameters))
  end
end

#display(name, pattern = nil) ⇒ Object



41
42
43
# File 'lib/humidifier/reservoir/cli.rb', line 41

def display(name, pattern = nil)
  puts Stack.new(name, pattern: pattern && /#{pattern}/i).to_cf
end

#upload(name = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/humidifier/reservoir/cli.rb', line 46

def upload(name = nil)
  stack_names = stack_names_from(name)
  authorize

  stack_names.each do |stack_name|
    stack = Stack.new(stack_name)
    puts "Uploading #{stack.stack_name}"
    stack.upload
  end
end

#validate(name = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/humidifier/reservoir/cli.rb', line 59

def validate(name = nil)
  stack_names = stack_names_from(name)
  authorize

  print 'Validating... '

  if stack_names.all? { |stack_name| Stack.new(stack_name).valid? }
    puts 'Valid.'
  else
    puts 'Invalid.'
  end
end