From 7dd199cbd0d179286ac9641a20f4f2d6e5ca2326 Mon Sep 17 00:00:00 2001 From: Brian Sidebotham Date: Tue, 21 Jun 2022 13:54:44 +0100 Subject: [PATCH 1/3] Fixes #30072 - Update documentation to show that the old DIR option can target a single file instead --- internal/command/fmt.go | 9 +++++---- website/docs/cli/commands/fmt.mdx | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/command/fmt.go b/internal/command/fmt.go index 625e69326b5e..aff52e9d5f73 100644 --- a/internal/command/fmt.go +++ b/internal/command/fmt.go @@ -528,15 +528,16 @@ func (c *FmtCommand) trimNewlines(tokens hclwrite.Tokens) hclwrite.Tokens { func (c *FmtCommand) Help() string { helpText := ` -Usage: terraform [global options] fmt [options] [DIR] +Usage: terraform [global options] fmt [options] [TARGET] 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 DIR is not specified then the current working directory will be used. - If DIR is "-" then content will be read from STDIN. The given content must - be in the Terraform language native syntax; JSON is not supported. + If TARGET is not specified then the current working directory will be + used. If TARGET is a file, only that file will be used. If TARGET is + "-" then content will be read from STDIN. The given content must be in + the Terraform language native syntax; JSON is not supported. Options: diff --git a/website/docs/cli/commands/fmt.mdx b/website/docs/cli/commands/fmt.mdx index c6868d733f9f..4279eb182fed 100644 --- a/website/docs/cli/commands/fmt.mdx +++ b/website/docs/cli/commands/fmt.mdx @@ -45,12 +45,13 @@ and the generated files. ## Usage -Usage: `terraform fmt [options] [DIR]` +Usage: `terraform fmt [options] [TARGET]` 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). +a directory is provided for the `target` argument then it will scan that +given directory instead. If `target` is a file then `fmt` will process just +that file, and if a single dash (`-`) then `fmt` will read from standard input +(STDIN). The command-line flags are all optional. The list of available flags are: From 26e770321f3c651e0bc10c3c16aa1ea50f02794c Mon Sep 17 00:00:00 2001 From: Brian Sidebotham Date: Tue, 28 Jun 2022 19:42:47 +0100 Subject: [PATCH 2/3] Update website/docs/cli/commands/fmt.mdx Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com> --- website/docs/cli/commands/fmt.mdx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/website/docs/cli/commands/fmt.mdx b/website/docs/cli/commands/fmt.mdx index 4279eb182fed..99ae10754dc7 100644 --- a/website/docs/cli/commands/fmt.mdx +++ b/website/docs/cli/commands/fmt.mdx @@ -48,10 +48,7 @@ and the generated files. Usage: `terraform fmt [options] [TARGET]` By default, `fmt` scans the current directory for configuration files. If -a directory is provided for the `target` argument then it will scan that -given directory instead. If `target` is a file then `fmt` will process just -that file, and if a single dash (`-`) then `fmt` will read from standard input -(STDIN). +you provide a directory for the `target` argument, then `fmt` will scan that directory instead. If you provide a file, then `fmt` will process just that file. If you provide a single dash (`-`), then `fmt` will read from standard input (STDIN). The command-line flags are all optional. The list of available flags are: From a6aa75931b428d1413da49a3f32703dec13fd49d Mon Sep 17 00:00:00 2001 From: Brian Sidebotham Date: Tue, 28 Jun 2022 19:43:41 +0100 Subject: [PATCH 3/3] Update internal/command/fmt.go Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com> --- internal/command/fmt.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/command/fmt.go b/internal/command/fmt.go index aff52e9d5f73..b57bc302bfd6 100644 --- a/internal/command/fmt.go +++ b/internal/command/fmt.go @@ -530,14 +530,16 @@ func (c *FmtCommand) Help() string { helpText := ` Usage: terraform [global options] fmt [options] [TARGET] - 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 TARGET is not specified then the current working directory will be - used. If TARGET is a file, only that file will be used. If TARGET is - "-" then content will be read from STDIN. The given content must be in - the Terraform language native syntax; JSON is not supported. + 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 TARGET is not specified, the command uses the current working directory. + If TARGET is a file, the command only uses the specified file. If TARGET + is "-" then the command reads from STDIN. + + The content must be in the Terraform language native syntax; JSON is not + supported. Options: