Sha256: 9b1751ab07a00170b23367fe85d143f6149851080ef6c5bf1228616c9aba83a7

Contents?: true

Size: 1.67 KB

Versions: 32

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env ruby

require 'cfndsl'
require 'optparse'

options = {}

optparse = OptionParser.new do|opts|
  opts.banner = "Usage: cfndsl [options] FILE"

  # Define the options, and what they do
  options[:output] = '-'
  opts.on( '-o', '--output FILE', 'Write output to file' ) do |file|
    options[:output] = file
  end

  options[:extras] = []
  opts.on( '-y', '--yaml FILE', 'Import yaml file as local variables' ) do |file|
    options[:extras].push([:yaml,File.expand_path(file)])
  end

  opts.on( '-r', '--ruby FILE', 'Evaluate ruby file before template' ) do |file|
    options[:extras].push([:ruby,File.expand_path(file)])
  end

  opts.on( '-j', '--json FILE', 'Import json file as local variables' ) do |file|
    options[:extras].push([:json,File.expand_path(file)])
  end


  opts.on( '-D', '--define "VARIABLE=VALUE"', 'Directly set local VARIABLE as VALUE' ) do |file|
    options[:extras].push([:raw,file])
  end

  options[:verbose] = false
  opts.on('-v', '--verbose', "Turn on verbose ouptut") do
    options[:verbose] = true
  end

  # This displays the help screen, all programs are
  # assumed to have this option.
  opts.on( '-h', '--help', 'Display this screen' ) do
    puts opts
    exit
  end
end

optparse.parse!
unless ARGV[0] then
  puts optparse.help
  exit(1)
end

filename = File.expand_path(ARGV[0])
verbose = options[:verbose] && STDERR

model = CfnDsl::eval_file_with_extras(filename, options[:extras], verbose)

output = STDOUT
if options[:output] != '-' then
  verbose.puts("Writing to #{options[:output]}") if verbose
  output = File.open( File.expand_path(options[:output]), "w")
else
  verbose.puts("Writing to STDOUT") if verbose
end

output.puts model.to_json

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cfndsl-0.3.6 bin/cfndsl
cfndsl-0.3.5 bin/cfndsl
cfndsl-0.3.4 bin/cfndsl
cfndsl-0.3.3 bin/cfndsl
cfndsl-0.3.2 bin/cfndsl
cfndsl-0.3.1 bin/cfndsl
cfndsl-0.2.9 bin/cfndsl
cfndsl-0.2.8 bin/cfndsl
cfndsl-0.3.0 bin/cfndsl
cfndsl-0.2.7 bin/cfndsl
cfndsl-0.2.4 bin/cfndsl
cfndsl-0.2.3 bin/cfndsl
cfndsl-0.2.2 bin/cfndsl
cfndsl-0.2.1 bin/cfndsl
cfndsl-0.2.0 bin/cfndsl
cfndsl-0.1.20 bin/cfndsl
cfndsl-0.1.19 bin/cfndsl
cfndsl-0.1.18 bin/cfndsl
cfndsl-0.1.17 bin/cfndsl
cfndsl-0.1.16 bin/cfndsl