class RubyTerraform::Commands::Format

Wraps the +terraform fmt+ command which rewrites all terraform configuration files to a canonical format.

Both configuration files (.tf) and variables files (.tfvars) are updated. JSON files (.tf.json or .tfvars.json) are not modified.

If :directory is not specified in the parameters map then the current working directory will be used. If :directory is +“-”+ then content will be read from the standard input. The given content must be in the terraform language native syntax; JSON is not supported.

For options accepted on construction, see {#initialize}.

When executing an instance of {Format} via {#execute}, the following options are supported:

@example Basic Invocation

RubyTerraform::Commands::Format.new.execute(
  directory: 'infra/networking')

Public Instance Methods

arguments(parameters) click to toggle source

@!visibility private

# File lib/ruby_terraform/commands/format.rb, line 68
def arguments(parameters)
  [parameters[:directory]]
end
options() click to toggle source

@!visibility private

Calls superclass method RubyTerraform::Options::Global#options
# File lib/ruby_terraform/commands/format.rb, line 56
def options
  %w[
    -list
    -write
    -diff
    -check
    -no-color
    -recursive
  ] + super
end
subcommands() click to toggle source

@!visibility private

# File lib/ruby_terraform/commands/format.rb, line 51
def subcommands
  %w[fmt]
end