conn3x fmt
conn3x fmt rewrites configuration files in the standard layout: consistent indentation, aligned = signs, and spacing. It changes layout only, never meaning.
conn3x fmt [options] [PATH...]With no PATH, it formats the current directory. A directory formats the files in it, a file formats that file, and - reads from standard input and writes the result to standard output.
What Conn3x changes
Section titled “What Conn3x changes”fmt formats .circuit.hcl files along with .tf, .tofu, .tfvars, .tftest.hcl and .tofutest.hcl files. A directory scan picks them up, and you can name one directly:
conn3x fmt web.circuit.hclSo conn3x fmt -check -recursive in CI covers your circuits as well.
Options
Section titled “Options”| Option | Description |
|---|---|
-check |
Change nothing, and exit 3 if any file needs formatting. Lists the files that do. |
-diff |
Print the changes as a diff. |
-write=false |
Don’t write to the files. Use it with -diff to preview. |
-list=false |
Don’t print the names of the files that changed. |
-recursive |
Format subdirectories too. |
-no-color |
Don’t use terminal colors. |
See OpenTofu’s fmt page for more.
Examples
Section titled “Examples”Format everything under the current directory:
conn3x fmt -recursiveFail CI when a file isn’t formatted:
conn3x fmt -check -recursivePreview the changes:
$ conn3x fmt -diff -write=falsemain.tf--- old/main.tf+++ new/main.tf@@ -1,3 +1,3 @@ variable "region" {-type=string+ type = string }Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Success. With -check, every file is formatted. |
| 2 | An error, such as a syntax error or a file type fmt doesn’t handle. |
| 3 | Only with -check: some files need formatting. |