Skip to content

Commit

Permalink
Add a table for flag readability
Browse files Browse the repository at this point in the history
  • Loading branch information
rkoron007 committed Dec 12, 2024
1 parent b7d9063 commit 76dea21
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
31 changes: 14 additions & 17 deletions website/docs/cli/commands/fmt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@ and the generated files.

Usage: `terraform fmt [options] [target...]`

By default, `fmt` scans the current directory for configuration files. If 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. If no flag is given, `fmt` rewrites
the Terraform configuration files to a canonical format and style.

The following flags are available:

* `-list=false` - Don't list the files containing formatting inconsistencies.
* `-write=false` - Don't overwrite the input files. (This is implied by `-check` or when the input is STDIN.)
* `-diff` - Display diffs of formatting changes.
* `-check` - Check if the input is formatted. Exit status will be 0 if all input is properly formatted. If not, exit status will be non-zero and the command will output a list of filenames whose files are not properly formatted.
* `-recursive` - Also process files in subdirectories. By default, only the given directory (or current directory) is processed.
By default, the `terraform fmt` command scans your current directory for configuration files. You can also provide a `target` argument to tell `terraform fmt` to scan:
* A directory
* A specific file
* Standard input by supplying a single dash (`-`).

The `terraform fmt` command accepts the following arguments.

| Flag | Description | Required |
| :---- | :---- | :---- |
| `-list=false` | Prevents the command from listing the files containing formatting inconsistencies. | Optional |
| `-diff` | Displays the diffs of formatting changes. | Optional |
| `-write=false` | Prevents the command from overwriting files. This behavior is implied by the `-check` flag or if the input is from `STDIN`. | Optional |
| `-check` | Checks if the input is formatted. The exit status is `0` if the command's input is properly formatted. Otherwise, the exit status is non-zero, and the command outputs a list of improperly formatted file names. | Optional |
| `-recursive` | Processes files in subdirectories in addition to the current directory. By default, the command only processes the specified, or current, directory. | Optional |
17 changes: 16 additions & 1 deletion website/docs/language/stacks/reference/tfstacks-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,24 @@ The `tfstacks plan` accepts the following arguments.
The `tfstacks fmt` command scans your current directory for Stack configuration files, `.tfstack.hcl` and `.tfdeploy.hcl`, and formats those files to match Terraform's canonical format and style.

```shell-session
$ tfstacks fmt
$ tfstacks fmt [options] [target]
```

By default, the `tfstacks fmt` command scans your current directory for configuration files. You can also provide a `target` argument to tell `tfstacks fmt` to scan:
* A directory
* A specific file
* Standard input by supplying a single dash (`-`).

The `tfstacks fmt` command accepts the following arguments.

| Flag | Description | Required |
| :---- | :---- | :---- |
| `-list=false` | Prevents the command from listing the files containing formatting inconsistencies. | Optional |
| `-diff` | Displays the diffs of formatting changes. | Optional |
| `-write=false` | Prevents the command from overwriting files. This behavior is implied by the `-check` flag or if the input is from `STDIN`. | Optional |
| `-check` | Checks if the input is formatted. The exit status is `0` if the command's input is properly formatted. Otherwise, the exit status is non-zero, and the command outputs a list of improperly formatted file names. | Optional |
| `-recursive` | Processes files in subdirectories in addition to the current directory. By default, only the specified directory is processed. | Optional |

The `tfstacks fmt` command uses the same formatting rules as the Terraform CLI's `terraform fmt` command. Refer to [`terraform fmt`](/terraform/cli/commands/fmt) for more information on formatting rules.

## Global options
Expand Down

0 comments on commit 76dea21

Please sign in to comment.