Skip to content

Commit ab3a613

Browse files
authored
Merge pull request #227 from oferchen/codex/update-documentation-for-supported-blocks-and-cli
docs: document supported blocks and schema flags
2 parents 9c6be75 + cce45d4 commit ab3a613

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ This process is idempotent: running the tool multiple times yields the same resu
1313

1414
## Supported Blocks
1515

16-
`hclalign` currently aligns attributes inside Terraform `variable` blocks. Other block types are left untouched.
16+
`hclalign` aligns attributes inside Terraform blocks including `variable`, `output`, `locals`, `module`, `provider`, `terraform`, `resource`, `data`, `dynamic`, `lifecycle`, and `provisioner`.
1717

1818
## Schema Options
1919

2020
The default schema orders variable attributes as `description`, `type`, `default`, `sensitive`, `nullable`. Override it with `--order` and enforce that only those attributes appear by adding `--strict-order`.
2121

22+
## Formatting Strategies
23+
24+
The fmt phase supports multiple strategies controlled by `--fmt-strategy`:
25+
`auto` chooses the Terraform binary if available, `binary` always shells out to
26+
`terraform fmt`, and `go` uses the built-in formatter. Use `--fmt-only` to stop
27+
after formatting or `--no-fmt` to skip this phase.
28+
29+
## Provider Schema Integration
30+
31+
Resource and data blocks can be ordered according to provider schemas. Supply a
32+
schema file via `--providers-schema` or let `hclalign` invoke `terraform
33+
providers schema -json` by passing `--use-terraform-schema`. Unknown attributes
34+
fall back to alphabetical order.
35+
2236
## CLI Flags
2337

2438
- `--write` (default): rewrite files in place
@@ -27,9 +41,14 @@ The default schema orders variable attributes as `description`, `type`, `default
2741
- `--stdin`, `--stdout`: read from stdin and/or write to stdout
2842
- `--include`, `--exclude`: glob patterns controlling which files are processed
2943
- `--follow-symlinks`: traverse symbolic links
30-
- `--order`, `--strict-order`: control and enforce schema ordering
44+
- `--order`, `--strict-order`: control schema ordering; `--strict-order` applies globally to all blocks
3145
- `--concurrency`: maximum parallel file processing
3246
- `-v, --verbose`: enable verbose logging
47+
- `--fmt-only`: run only the formatting phase
48+
- `--no-fmt`: skip the formatting phase
49+
- `--fmt-strategy {auto,binary,go}`: choose formatting backend
50+
- `--providers-schema`: path to a provider schema JSON file
51+
- `--use-terraform-schema`: derive schema via `terraform providers schema -json`
3352

3453
## Atomic Writes and BOM Preservation
3554

0 commit comments

Comments
 (0)