Sha256: e1d91b625c120a49f5c7fc75b9e5b9505a4c20f467f375f9e407c326430a8a6a

Contents?: true

Size: 1.44 KB

Versions: 17

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module MuxTf
  module Cli
    module PlanSummary
      extend PiotrbCliUtils::Util
      extend PiotrbCliUtils::ShellHelpers
      extend TerraformHelpers

      class << self
        def run(args)
          options = {
            interactive: false,
            hierarchy: false
          }

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

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

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

          if options[:interactive]
            abort_message = catch :abort do
              plan.run_interactive
            end
            if abort_message
              log Paint["Aborted: #{abort_message}", :red]
            end
          else
            if options[:hierarchy]
              plan.nested_summary.each do |line|
                puts line
              end
            else
              plan.flat_summary.each do |line|
                puts line
              end
            end
            puts
            puts plan.summary
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mux_tf-0.5.3 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.5.2 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.5.1 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.5.0 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.9 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.8 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.7 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.6 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.5 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.4 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.3 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.2 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.4.0 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.3.3 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.3.2 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.3.1 lib/mux_tf/cli/plan_summary.rb
mux_tf-0.3.0 lib/mux_tf/cli/plan_summary.rb