class Stax::Cli
Public Class Methods
exit_on_failure?()
click to toggle source
silence deprecation warning github.com/erikhuda/thor/blob/fb625b223465692a9d8a88cc2a483e126f1a8978/CHANGELOG.md#100
# File lib/stax/cli.rb, line 14 def self.exit_on_failure? true end
Public Instance Methods
change()
click to toggle source
# File lib/stax/cli/crud.rb, line 50 def change stack_objects.each do |s| if s.exists? s.change end end end
create()
click to toggle source
# File lib/stax/cli/crud.rb, line 19 def create stacks = stack_objects ## filter by stack groups unless options[:all] stacks.reject! do |s| (s.stack_groups.map(&:to_s) & options[:groups]).empty? # test intersection end end stacks.each do |s| if s.exists? say("Skipping: #{s.stack_name} exists", :yellow) elsif y_or_n?("Create #{s.stack_name}?", :yellow) s.create end end end
delete()
click to toggle source
# File lib/stax/cli/crud.rb, line 60 def delete stack_objects.reverse.each do |s| if s.exists? s.invoke(:delete, [], options) else say("#{s.stack_name} does not exist", :green) end end end
generate(name = nil, *args)
click to toggle source
# File lib/stax/cli/generate.rb, line 7 def generate(name = nil, *args) Stax::Generators.load_builtin_generators Stax::Generators.load_local_generators if name.nil? Stax::Generators::Base.subclasses.each do |g| say_status(g.command_name, g.desc, :bold) end else klass = Stax::Generators.find(name) fail_task("Unknown generator #{name}") unless klass klass.start(args) end end
ls(prefix = nil)
click to toggle source
# File lib/stax/cli/ls.rb, line 36 def ls(prefix = nil) if options[:account] ls_account_stacks elsif options[:all] ls_stacks_with_prefix(prefix) else ls_staxfile_stacks end end
ls_account_stacks()
click to toggle source
# File lib/stax/cli/ls.rb, line 25 def ls_account_stacks print_table Aws::Cfn.stacks.map { |s| [s.stack_name, s.creation_time, color(s.stack_status, Aws::Cfn::COLORS), s.template_description] }.sort end
ls_stacks_with_prefix(prefix)
click to toggle source
# File lib/stax/cli/ls.rb, line 17 def ls_stacks_with_prefix(prefix) print_table Aws::Cfn.stacks.select { |s| s.stack_name.start_with?(prefix || stack_prefix) }.map { |s| [s.stack_name, s.creation_time, color(s.stack_status, Aws::Cfn::COLORS), s.template_description] }.sort end
ls_staxfile_stacks()
click to toggle source
# File lib/stax/cli/ls.rb, line 5 def ls_staxfile_stacks stacks = Aws::Cfn.stacks.each_with_object({}) { |s, h| h[s.stack_name] = s } print_table Stax.stack_list.map { |id| name = stack(id).stack_name if (s = stacks[name]) [s.stack_name, s.creation_time, color(s.stack_status, Aws::Cfn::COLORS), s.template_description] else options[:existing] ? nil : [name, '-'] end }.compact end
new(dir)
click to toggle source
# File lib/stax/cli/new.rb, line 5 def new(dir) Stax::Generators.load_builtin_generators Stax::Generators::NewGenerator.start(Array(dir)) end
stack_objects()
click to toggle source
# File lib/stax/cli/crud.rb, line 11 def stack_objects stack_order.map(&method(:stack)) end
stack_order()
click to toggle source
create order: default to stacks from Staxfile, override if needed delete will be this, in reverse order
# File lib/stax/cli/crud.rb, line 7 def stack_order Stax.stack_list end
update()
click to toggle source
# File lib/stax/cli/crud.rb, line 39 def update stack_objects.each do |s| if s.exists? y_or_n?("Update #{s.stack_name}?", :yellow) && s.update else say("#{s.stack_name} does not exist") end end end
version()
click to toggle source
# File lib/stax/cli/version.rb, line 7 def version puts Stax::VERSION end