### Install tffumpt with Go toolchain Source: https://github.com/aleksac/tffumpt/blob/main/README.md Installs the tffumpt CLI using the go install command. ```shell go install github.com/AleksaC/tffumpt/cmd/tffumpt@latest ``` -------------------------------- ### Install tffumpt via wget script Source: https://github.com/aleksac/tffumpt/blob/main/README.md Alternative installation method using wget to fetch and execute the install script. ```shell wget -O- -nv https://raw.githubusercontent.com/AleksaC/tffumpt/refs/heads/main/install.sh | sh ``` -------------------------------- ### Install tffumpt via curl script Source: https://github.com/aleksac/tffumpt/blob/main/README.md Downloads and runs the official install script from the tffumpt GitHub repository. ```shell curl -sSfL https://raw.githubusercontent.com/AleksaC/tffumpt/refs/heads/main/install.sh | sh ``` -------------------------------- ### Show tffumpt help Source: https://github.com/aleksac/tffumpt/blob/main/README.md Displays the CLI help information for tffumpt. ```shell tffumpt -help ``` -------------------------------- ### Direct download tffumpt binary Source: https://github.com/aleksac/tffumpt/blob/main/README.md Downloads a specific release zip, extracts it, and moves the binary to ~/.local/bin/. Replace darwin and arm64 with your OS and CPU architecture. ```shell cd /tmp curl -O https://github.com/AleksaC/tffumpt/releases/download/v0.1.0/tffumpt-v0.1.0-darwin-arm64.zip unzip -oqj "${ARCHIVE_NAME}" -x "LICENSE*" "README*" mv ./tffumpt ~/.local/bin/ ``` -------------------------------- ### Run all checks with make check Source: https://github.com/aleksac/tffumpt/blob/main/CONTRIBUTING.md Use this command to run all project checks, including tests, lint, and pre-commit, before requesting a review. Requires the Go toolchain and optionally pre-commit for linters and formatters. ```bash make check ``` -------------------------------- ### Bare expression in map keys wrapping: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Wraps expression in parentheses if it's used as a map key. The first block shows the input without parentheses; the second shows the formatted output with parentheses. ```hcl map = { upper(var.foo) = "bar" } ``` ```hcl map = { (upper(var.foo)) = "bar" } ``` -------------------------------- ### Format terraform files non-recursively Source: https://github.com/aleksac/tffumpt/blob/main/README.md Runs tffumpt in the current directory to format all terraform files without recursing into subdirectories. ```shell tffumpt ``` -------------------------------- ### # for comments: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Enforces usage of `#` for single-line comments. The first block shows the input with `//`; the second shows the formatted output with `#`. ```hcl // comment ``` ```hcl # comment ``` -------------------------------- ### Newlines between top level blocks: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Adds a blank line between top-level blocks. The first block shows the input without a blank line; the second shows the formatted output with a blank line. ```hcl resource "foo" "bar" { a = "b" } resource "bar" "baz" { b = "c" } ``` ```hcl resource "foo" "bar" { a = "b" } resource "bar" "baz" { b = "c" } ``` -------------------------------- ### Space before comment text: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Adds a space between `#` and the comment text. The first block shows the input without a space; the second shows the formatted output with a space. ```hcl #comment ``` ```hcl # comment ``` -------------------------------- ### No unnecessary interpolation in map keys: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Replaces traditional string interpolation with parenthesized expressions for dynamic map keys. The first block shows the input with `${var.foo}`; the second shows the formatted output with `(var.foo)`. ```hcl map = { "${var.foo}" = "bar" } ``` ```hcl map = { (var.foo) = "bar" } ``` -------------------------------- ### Configure pre-commit hook for tffumpt Source: https://github.com/aleksac/tffumpt/blob/main/README.md Adds a pre-commit hook configuration to .pre-commit-config.yaml to run tffumpt on your Terraform files. ```yaml repos: - repo: https://github.com/AleksaC/tffumpt rev: v0.1.1 hooks: - id: tffumpt ``` -------------------------------- ### Map for expression key unwrapping: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Removes unnecessary string interpolation in map for expression keys. The first block shows the input with `${foo.a}`; the second shows the formatted output with `foo.a`. ```hcl map = { for foo in var.bar: "${foo.a}" => foo.b } ``` ```hcl map = { for foo in var.bar: foo.a => foo.b } ``` -------------------------------- ### No extra newlines: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Limits blank lines between blocks and attributes to 1, removes leading/trailing newlines inside blocks and multiline literals. The first block shows the input with extra newlines; the second shows the formatted output. ```hcl resource "foo" "bar" { a = "b" } resource "bar" "baz" { b = "c" } ``` ```hcl resource "foo" "bar" { a = "b" } resource "bar" "baz" { b = "c" } ``` -------------------------------- ### No extraneous parentheses: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Removes parentheses that serve no purpose. The first block shows the input with unnecessary parentheses; the second shows the formatted output. ```hcl foo = lower(("Hello")) bar = (2 + 2) ``` ```hcl foo = lower("Hello") bar = 2 + 2 ``` -------------------------------- ### = over : in map literals: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Enforces usage of `=` between key and value in map literals. The first block shows the input with `:`; the second shows the formatted output with `=`. ```hcl map = { foo : "bar" bar : "baz" } ``` ```hcl map = { foo = "bar" bar = "baz" } ``` -------------------------------- ### No commas in multiline map literals: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Removes commas between map items in multiline map literals. The first block shows the input with commas; the second shows the formatted output without commas. ```hcl map = { foo = "bar", bar = "baz" } ``` ```hcl map = { foo = "bar" bar = "baz" } ``` -------------------------------- ### Trailing commas in multiline list literals: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Adds a trailing comma in multiline list literals. The first block shows the input without a trailing comma; the second shows the formatted output with a trailing comma. ```hcl list = [ "foo", "bar", "baz" ] ``` ```hcl list = [ "foo", "bar", "baz", ] ``` -------------------------------- ### No extraneous quotes in map literal keys: before and after Source: https://github.com/aleksac/tffumpt/blob/main/README.md Removes quotes from map keys that don't need to be quoted. The first block shows the input with quoted keys; the second shows the formatted output without quotes. ```hcl map = { "foo" = "bar" "bar" = "baz" } ``` ```hcl map = { foo = "bar" bar = "baz" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.