module Ruby module Terraform module Commands class InitCommand include ExecutionSupport attr_accessor :dir attr_accessor :backend attr_accessor :backend_config def initialize(opts = {}) @dir = opts[:dir] @backend = opts[:backend] @backend_config = opts[:backend_config] end def command cmd = %W[#{tf_binary} init] cmd += ['-backend', backend] if backend if backend_config backend_config.each do |key, value| cmd += ['-backend-config', "#{key}=#{value}"] end end cmd += [dir] if dir cmd end end end end end