Sha256: d538493b4753cb42fc16cae018bf77f5f61047ada3f5ba935cf40a70d089b8e2
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
require 'trollop' module Stackster module CLI def self.start @opts = Trollop::options do banner <<-EOS I build and manage AWS Cloud Formation Stacks stackster list stackster create -n STACK_NAME -a ATTRIBUTES -t TEMPLATE_PATH stackster update -n STACK_NAME -a ATTRIBUTES stackster show -n STACK_NAME stackster destroy -n STACK_NAME Attributes are specified as '=' seperated key value pairs. Multiple can be specified. For example: stackster create -n test-stack -t ~/my-template.json -a arg1=val1 -a arg2=vol2 EOS opt :help, "Display Help" opt :attributes, "= seperated attribute and it's value", :type => :string, :multi => true opt :name, "Stack name to manage", :type => :string opt :template, "Path to the template file", :type => :string end @cmd = ARGV.shift case @cmd when 'create', 'destroy', 'delete', 'list', 'update', 'show' @s = Stack.new :name => @opts[:name], :config => nil end case @cmd when 'create' @s.create :attributes => attributes, :template => @opts[:template] puts "#{@opts[:name]} created." when 'update' @s.update :attributes => attributes puts "#{@opts[:name]} updated." when 'destroy', 'delete' @s.destroy puts "#{@opts[:name]} destroyed." when 'show' puts @s.display.to_yaml when 'list' puts StackLister.new.all else puts "Unkown command '#{@cmd}'" end end private def self.attributes attrs = [] read_attributes.each do |attribs| a = attribs.split('=') attrs << { a.first.gsub(/\s+/, "") => a.last } end attrs end def self.read_attributes @opts[:attributes].nil? ? [] : @opts[:attributes] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stackster-0.2.2 | lib/stackster/cli.rb |
stackster-0.2.1 | lib/stackster/cli.rb |