bin/cfnlego in cfnlego-0.0.5 vs bin/cfnlego in cfnlego-0.0.6

- old
+ new

@@ -1,31 +1,29 @@ #!/usr/bin/env ruby require_relative '../lib/cfnlego' require 'optparse' require 'ruby-beautify' -@indent_token = " " -@indent_count = 2 include RubyBeautify -options = {resources: []} +options = {resources: [], indent_token: " ", indent_count: 2} OptionParser.new do |opts| opts.banner = "Usage: cfnlego --reousrce resource [options]" opts.on("-r", "--resource RESOURCE_TYPE,RESOURCE_LOGICAL_NAME", "Add resource type and logical name") do |r| options[:resources] << r end opts.on("-i", "--indent TOKEN", "Use TOKEN for indent character (default space)") do |i| - @indent_token = i + options[:indent_token] = i end opts.on("-c", "--indent-count [COUNT]", Integer, "Count of characters to use for indenting. (default: 2)") \ do |count| - @indent_count = count + options[:indent_count] = count end opts.on("-h", "--help", "Prints this help") do puts opts puts <<-EXAMPLE @@ -36,10 +34,15 @@ --reousrce IAM::InstanceProfile,InstanceProfile \\ EXAMPLE exit end + + opts.on("-v", "--version", "Show version") do + puts Cfnlego::VERSION + exit + end end.parse! # Constructure Resources resources = [] options[:resources].each do |r| @@ -49,7 +52,7 @@ resources << Cfnlego::Resource.new(type, name) end end puts pretty_string Cfnlego::CloudFormation.new(resources).render, - indent_token: @indent_token, - indent_count: @indent_count + indent_token: options[:indent_token], + indent_count: options[:indent_count]