Module: MuxTf::Cli::PlanSummary

Extended by:
TerraformHelpers, PiotrbCliUtils::ShellHelpers, PiotrbCliUtils::Util
Includes:
MuxTf::Coloring
Defined in:
lib/mux_tf/cli/plan_summary.rb

Class Method Summary collapse

Methods included from TerraformHelpers

tf_apply, tf_force_unlock, tf_init, tf_plan, tf_show, tf_stream_helper, tf_validate

Methods included from MuxTf::Coloring

included, #pastel

Class Method Details

.run(args) ⇒ Object



12
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
# File 'lib/mux_tf/cli/plan_summary.rb', line 12

def run(args)
  options = {
    hierarchy: false
  }

  args = OptionParser.new { |opts|
    opts.on("-h") do |v|
      options[:hierarchy] = v
    end
  }.parse!(args)

  raise "must specify plan file in interactive mode" if options[:interactive] && args[0].blank?

  plan = if args[0]
           PlanSummaryHandler.from_file(args[0])
         else
           PlanSummaryHandler.from_data(JSON.parse($stdin.read))
         end

  if options[:hierarchy]
    plan.nested_summary.each do |line|
      puts line
    end
  else
    plan.flat_summary.each do |line|
      puts line
    end
    plan.output_summary.each do |line|
      puts line
    end
  end
  puts
  puts plan.summary
end