Module: Proteus::Commands::Render

Defined in:
lib/proteus/commands/render.rb

Class Method Summary collapse

Class Method Details

.included(thor_class) ⇒ Object



6
7
8
9
10
11
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
# File 'lib/proteus/commands/render.rb', line 6

def self.included(thor_class)
  thor_class.class_eval do

    desc "render", "Renders the module templates"
    long_desc <<-LONGDESC
      Renders the module templates without running Terraform
    LONGDESC
    option :init, type: :boolean, default: false
    def render
      render_backend
      module_manager = Proteus::Modules::Manager.new(context: context, environment: environment)
      module_manager.render_modules

      fmt_cmd = <<~FMT_CMD
        cd #{context_path(context)} && \
        terraform fmt -list=true .
      FMT_CMD

      fmt_output = syscall(
        fmt_cmd.squeeze(' '),
        capture: true,
        suppress: true
      )

      init(verbose: parent_options[:verbose]) if options[:init]

      say "Formatted files:", :green
      say fmt_output, :green
    end
  end
end