Class: Humidifier::CLI

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

Overview

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

Instance Method Summary collapse

Instance Method Details

#change(name = nil) ⇒ Object



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

def change(name = nil)
  authorize

  stack_names_from(name).each do |stack_name|
    directory = Directory.new(stack_name)

    puts "🛠 Creating a changeset for #{directory.stack_name}"
    directory.create_change_set
  end
end

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



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

def deploy(name = nil, *parameters)
  authorize

  stack_names_from(name).each do |stack_name|
    directory = Directory.new(stack_name, prefix: options[:prefix])

    puts "🚀 Deploying #{directory.stack_name}"
    directory.deploy(options[:wait], parameters_from(parameters))
  end
end

#display(name, pattern = nil) ⇒ Object



42
43
44
45
46
47
# File 'lib/humidifier/cli.rb', line 42

def display(name, pattern = nil)
  directory = Directory.new(name, pattern: pattern && /#{pattern}/i)

  puts "📄 Displaying #{directory.stack_name}"
  puts directory.to_cf
end

#stacksObject



50
51
52
53
# File 'lib/humidifier/cli.rb', line 50

def stacks
  puts "🗒 Listing stacks"
  puts Humidifier.config.stack_names.sort.map { |name| "- #{name}" }
end

#upgradeObject



56
57
58
59
60
61
# File 'lib/humidifier/cli.rb', line 56

def upgrade
  print "💾 Downloading..."

  version = Upgrade.perform
  puts " upgraded to v#{version}"
end

#upload(name = nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/humidifier/cli.rb', line 64

def upload(name = nil)
  authorize

  stack_names_from(name).each do |stack_name|
    directory = Directory.new(stack_name)

    puts "📬 Uploading #{directory.stack_name}"
    directory.upload
  end
end

#validate(name = nil) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/humidifier/cli.rb', line 77

def validate(name = nil)
  authorize

  print "🔍 Validating... "

  valid =
    stack_names_from(name).all? do |stack_name|
      Directory.new(stack_name).valid?
    end

  puts valid ? "Valid." : "Invalid."
end

#versionObject



91
92
93
94
95
96
# File 'lib/humidifier/cli.rb', line 91

def version
  filepath = File.expand_path("../../#{SPECIFICATION}", __dir__)
  version = JSON.parse(File.read(filepath))["ResourceSpecificationVersion"]

  puts "📦 CloudFormation specification v#{version}"
end