From b0bcdfd9386b79ee24ff123e0b58870788553db7 Mon Sep 17 00:00:00 2001 From: rkoron007 Date: Wed, 11 Dec 2024 13:42:24 -0800 Subject: [PATCH 1/3] First shot at documenting --- .../stacks/reference/tfstacks-cli.mdx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/website/docs/language/stacks/reference/tfstacks-cli.mdx b/website/docs/language/stacks/reference/tfstacks-cli.mdx index 48a4892f6c04..30c794c7e948 100644 --- a/website/docs/language/stacks/reference/tfstacks-cli.mdx +++ b/website/docs/language/stacks/reference/tfstacks-cli.mdx @@ -72,10 +72,11 @@ $ sudo yum -y install terraform-stacks-cli The `terraform-stacks-cli` supports the following four commands: -* `tfstacks init` -* `tfstacks validate` -* `tfstacks providers lock [-platform=os_arch]` -* `tfstacks plan -organization=org_name -stack=stack_id -deployment=deployment_name [-hostname=hostname]` +* [`tfstacks init`](#tfstacks-init-command) +* [`tfstacks validate`](#tfstacks-validate-command) +* [`tfstacks providers lock [-platform=os_arch]`](#tfstacks-providers-lock-command) +* [`tfstacks plan -organization=org_name -stack=stack_id -deployment=deployment_name [-hostname=hostname]`](#tfstacks-plan-command) +* [`tfstacks fmt`](#tfstacks-fmt-command) Each Stack command supports [global options](#global-options). @@ -128,6 +129,19 @@ The `tfstacks plan` accepts the following arguments. | `-deployment=` | Set the `deployment` flag to the deployment name you want to perform this plan in. The deployment name must match one of the deployment names you specified in the `tfdeploy.hcl` file.

Alternatively, you can set an environment variable named `TFSTACKS_DEPLOYMENT` with the same value. | Required | | `-hostname=` | You can set the `hostname` flag to the hostname of the HCP Terraform instance you want to perform this plan in. The default value is `app.terraform.io`.

Alternatively, you can set an environment variable named `TFSTACKS_HOSTNAME` with the same value. | Optional | +### `tfstacks fmt` command + + +-> The `tfstacks fmt` command requires v0.6.0 of the `terraform-stacks-cli` or higher. Refer to [installation](#installation) for instructions. + +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 +``` + +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 You can apply the following global options to any `tfstacks` command: From b7d90633da5ec38d86a176c56f37c8fe737f0937 Mon Sep 17 00:00:00 2001 From: rkoron007 Date: Wed, 11 Dec 2024 13:50:47 -0800 Subject: [PATCH 2/3] Remove extra space --- website/docs/language/stacks/reference/tfstacks-cli.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/language/stacks/reference/tfstacks-cli.mdx b/website/docs/language/stacks/reference/tfstacks-cli.mdx index 30c794c7e948..60e358767861 100644 --- a/website/docs/language/stacks/reference/tfstacks-cli.mdx +++ b/website/docs/language/stacks/reference/tfstacks-cli.mdx @@ -131,7 +131,6 @@ The `tfstacks plan` accepts the following arguments. ### `tfstacks fmt` command - -> The `tfstacks fmt` command requires v0.6.0 of the `terraform-stacks-cli` or higher. Refer to [installation](#installation) for instructions. 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. From 76dea217381c9563090a4b3855a56c80b3583afe Mon Sep 17 00:00:00 2001 From: rkoron007 Date: Thu, 12 Dec 2024 11:22:39 -0800 Subject: [PATCH 3/3] Add a table for flag readability --- website/docs/cli/commands/fmt.mdx | 31 +++++++++---------- .../stacks/reference/tfstacks-cli.mdx | 17 +++++++++- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/website/docs/cli/commands/fmt.mdx b/website/docs/cli/commands/fmt.mdx index 5c5ad2f30403..33c72b60d564 100644 --- a/website/docs/cli/commands/fmt.mdx +++ b/website/docs/cli/commands/fmt.mdx @@ -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 | diff --git a/website/docs/language/stacks/reference/tfstacks-cli.mdx b/website/docs/language/stacks/reference/tfstacks-cli.mdx index 60e358767861..5f0ed006e33e 100644 --- a/website/docs/language/stacks/reference/tfstacks-cli.mdx +++ b/website/docs/language/stacks/reference/tfstacks-cli.mdx @@ -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