Sha256: 41700f0c6c35c2a0665ffe65bc76c64ebe485b65557cb3378b1417b38139e1ab

Contents?: true

Size: 978 Bytes

Versions: 12

Compression:

Stored size: 978 Bytes

Contents

require 'sparkle_formation'
require 'sfn'

module Sfn
  class Command
    # Print command
    class Print < Command

      include Sfn::CommandModule::Base
      include Sfn::CommandModule::Template
      include Sfn::CommandModule::Stack

      # Print the requested template
      def execute!
        config[:print_only] = true
        file = load_template_file

        json_content = format_json(parameter_scrub!(template_content(file)))

        if(config[:write_to_file])
          unless(File.directory?(File.dirname(config[:write_to_file])))
            run_action 'Creating parent directory' do
              FileUtils.mkdir_p(File.dirname(config[:write_to_file]))
              nil
            end
          end
          run_action "Writing template to file - #{config[:write_to_file]}" do
            File.write(config[:write_to_file], json_content)
            nil
          end
        else
          ui.puts json_content
        end
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sfn-3.0.22 lib/sfn/command/print.rb
sfn-3.0.20 lib/sfn/command/print.rb
sfn-3.0.18 lib/sfn/command/print.rb
sfn-3.0.16 lib/sfn/command/print.rb
sfn-3.0.14 lib/sfn/command/print.rb
sfn-3.0.12 lib/sfn/command/print.rb
sfn-3.0.10 lib/sfn/command/print.rb
sfn-3.0.8 lib/sfn/command/print.rb
sfn-3.0.6 lib/sfn/command/print.rb
sfn-3.0.4 lib/sfn/command/print.rb
sfn-3.0.2 lib/sfn/command/print.rb
sfn-3.0.0 lib/sfn/command/print.rb