Sha256: 337c1ef7538a31ebc56181e1587b17ed6964906ad78cf28db4c2f47a2b2fe224

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

#!/usr/bin/env ruby
require_relative '../lib/cfnlego'
require 'optparse'
require 'ruby-beautify'

include RubyBeautify
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|
    options[:indent_token] = i
  end

  opts.on("-c", 
          "--indent-count [COUNT]", 
          Integer, 
          "Count of characters to use for indenting. (default: 2)") \
  do |count| 
    options[:indent_count] = count
  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

  opts.on("-v", "--version", "Show version") do
    puts Cfnlego::VERSION
    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 pretty_string Cfnlego::CloudFormation.new(resources).render, 
                   indent_token: options[:indent_token], 
                   indent_count: options[:indent_count]

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cfnlego-0.1.1 bin/cfnlego
cfnlego-0.1.0 bin/cfnlego
cfnlego-0.0.9 bin/cfnlego
cfnlego-0.0.8 bin/cfnlego
cfnlego-0.0.6 bin/cfnlego