#!/usr/bin/env ruby require_relative '../lib/cfnlego' require 'optparse' options = {resources: []} 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("-h", "--help", "Prints this help") do puts opts puts <<-EXAMPLE Example: cfnlego \\ --reousrce AutoScaling::AutoScalingGroup,ASG \\ --reousrce IAM::Role,Role \\ --reousrce IAM::InstanceProfile,InstanceProfile \\ EXAMPLE exit end end.parse! # Constructure Resources resources = [] options[:resources].each do |r| /(.*),(.*)/.match(r) do |m| type = m[1] name = m[2] resources << Cfnlego::Resource.new(type, name) end end puts Cfnlego::CloudFormation.new(resources).render