Files
opentf/website/source/docs/commands/fmt.html.markdown
Dan Carley 79e2753e41 command/fmt: Disable list/write when using STDIN
These options don't make sense when passing STDIN. `-write` will raise an
error because there is no file to write to. `-list` will always say
`<standard input>`. So disable whenever using STDIN, making the command
much simpler:

    cat main.tf | terraform fmt -
2016-03-07 15:07:15 +00:00

936 B

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
docs Command: fmt docs-commands-fmt The `terraform fmt` command is used to rewrite Terraform configuration files to a canonical format and style.

Command: fmt

The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style.

Usage

Usage: terraform fmt [options] [DIR]

By default, fmt scans the current directory for configuration files. If the dir argument is provided then it will scan that given directory instead. If dir is a single dash (-) then fmt will read from standard input (STDIN).

The command-line flags are all optional. The list of available flags are:

  • -list=true - List files whose formatting differs (disabled if using STDIN)
  • -write=true - Write result to source file instead of STDOUT (disabled if using STDIN)
  • -diff=false - Display diffs instead of rewriting files