Class: Sfn::Command::Trace

Inherits:
Sfn::Command
  • Object
show all
Includes:
Sfn::CommandModule::Base, Sfn::CommandModule::Stack, Sfn::CommandModule::Template
Defined in:
lib/sfn/command/trace.rb

Overview

Trace command

Constant Summary

Constants included from Sfn::CommandModule::Template

Sfn::CommandModule::Template::DEFAULT_PROVIDER_NAME, Sfn::CommandModule::Template::MAX_PARAMETER_ATTEMPTS, Sfn::CommandModule::Template::TEMPLATE_IGNORE_DIRECTORIES

Constants inherited from Sfn::Command

CONFIG_BASE_NAME, VALID_CONFIG_EXTENSIONS

Instance Method Summary collapse

Methods included from Sfn::CommandModule::Stack

included

Methods included from Sfn::CommandModule::Template

included

Methods included from Sfn::CommandModule::Base

included

Methods inherited from Sfn::Command

#config, #initialize

Methods included from Sfn::CommandModule::Callbacks

#api_action!, #callbacks_for, #run_callbacks_for

Constructor Details

This class inherits a constructor from Sfn::Command

Instance Method Details

#execute!Object

Print the requested template



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sfn/command/trace.rb', line 13

def execute!
  config[:sparkle_dump] = true
  config[:print_only] = true
  file = load_template_file

  if !file.is_a?(SparkleFormation)
    raise "Cannot trace non-SparkleFormation template"
  else
    writer = proc do |audit_log, indent = ""|
      audit_log.each do |record|
        header = "#{indent}-> "
        header << ui.color(record.type.to_s.capitalize, :bold)
        header << " - #{record.name}"
        source = "#{indent} |  source: "
        if record.location.line > 0
          source << "#{record.location.path} @ #{record.location.line}"
        else
          source << ui.color(record.location.path, :yellow)
        end
        origin = "#{indent} |  caller: "
        if record.caller.line > 0
          origin << "#{record.caller.path} @ #{record.caller.line}"
        else
          origin << ui.color(record.caller.path, :yellow)
        end
        ui.info header
        ui.info source
        ui.info origin
        if record.audit_log.count > 0
          writer.call(record.audit_log, indent + " |")
        end
      end
    end
    ui.info ui.color("Trace information:", :bold)
    writer.call(file.audit_log)
  end
end