lib/simple_deploy/cli/create.rb in simple_deploy-0.6.4 vs lib/simple_deploy/cli/create.rb in simple_deploy-0.6.5

- old
+ new

@@ -1,12 +1,15 @@ require 'trollop' module SimpleDeploy module CLI + class Create + include Shared + def create - opts = Trollop::options do + @opts = Trollop::options do version SimpleDeploy::VERSION banner <<-EOS Create a new stack. @@ -21,26 +24,35 @@ :default => 'info' opt :name, "Stack name(s) of stack to deploy", :type => :string opt :template, "Path to the template file", :type => :string end - CLI::Shared.valid_options? :provided => opts, - :required => [:environment, :name, :template] + valid_options? :provided => @opts, + :required => [:environment, :name, :template] - config = Config.new.environment opts[:environment] + config = Config.new.environment @opts[:environment] - logger = SimpleDeployLogger.new :log_level => opts[:log_level] + attributes = parse_attributes :attributes => @opts[:attributes] - attributes = CLI::Shared.parse_attributes :attributes => opts[:attributes], - :logger => logger - - stack = Stack.new :environment => opts[:environment], - :name => opts[:name], + stack = Stack.new :environment => @opts[:environment], + :name => @opts[:name], :config => config, :logger => logger - stack.create :attributes => attributes, - :template => opts[:template] + rescue_stackster_exceptions_and_exit do + stack.create :attributes => attributes, + :template => @opts[:template] + end end + + def logger + @logger ||= SimpleDeployLogger.new :log_level => @opts[:log_level] + end + + def command_summary + 'Create a new stack' + end + end + end end