### Install hcledit from source Source: https://github.com/minamijoyo/hcledit/blob/master/README.md These commands clone the repository, navigate into the directory, and install hcledit using make, followed by a version check. ```bash git clone https://github.com/minamijoyo/hcledit cd hcledit/ make install hcledit version ``` -------------------------------- ### hcledit block get example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Retrieves a specific block from an HCL file. ```bash $ cat tmp/block.hcl | hcledit block get resource.foo.bar resource "foo" "bar" { attr1 = "val1" } ``` -------------------------------- ### hcledit block list example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Lists all blocks in a given HCL file. ```bash $ cat tmp/block.hcl | hcledit block list resource.foo.bar resource.foo.baz ``` -------------------------------- ### hcledit body get example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Retrieves the body of a specific block from an HCL file. ```bash $ cat tmp/body.hcl | hcledit body get resource.foo.bar attr1 = "val1" nested { attr2 = "val2" } ``` -------------------------------- ### hcledit block new example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Creates a new block in an HCL file. ```bash $ cat tmp/block.hcl | hcledit block new resource.foo.qux --newline resource "foo" "bar" { attr1 = "val1" } resource "foo" "baz" { attr1 = "val2" } resource "foo" "qux" { } ``` -------------------------------- ### hcledit fmt example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Formats an HCL file to a canonical style, correcting inconsistent spacing. ```bash $ cat tmp/fmt.hcl | hcledit fmt resource "foo" "bar" { attr1 = "val1" attr2 = "val2" } ``` -------------------------------- ### Install hcledit using Homebrew Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This command installs hcledit on macOS using the Homebrew package manager. ```bash brew install minamijoyo/hcledit/hcledit ``` -------------------------------- ### Get an attribute value Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This example demonstrates how to get the value of a nested attribute 'attr2' from an HCL file using hcledit. ```bash cat tmp/attr.hcl | hcledit attribute get resource.foo.bar.nested.attr2 ``` -------------------------------- ### Replace an attribute's name and value Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This example shows how to replace both the key and value of an attribute. ```bash cat tmp/attr.hcl | hcledit attribute replace resource.foo.bar.nested.attr2 attr3 '"val3"' ``` -------------------------------- ### Address escaping example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Demonstrates how to escape labels containing dots when referencing attributes. ```bash $ cat tmp/attr.hcl | hcledit attribute get 'resource.foo\.bar.nested.attr2' "val2" ``` -------------------------------- ### hcledit block rm example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Removes a block from an HCL file. ```bash $ cat tmp/block.hcl | hcledit block rm resource.foo.baz resource "foo" "bar" { attr1 = "val1" } ``` -------------------------------- ### hcledit block mv example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Moves (renames) a block within an HCL file. ```bash $ cat tmp/block.hcl | hcledit block mv resource.foo.bar resource.foo.qux resource "foo" "qux" { attr1 = "val1" } resource "foo" "baz" { attr1 = "val2" } ``` -------------------------------- ### Remove an attribute Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This example demonstrates removing an attribute 'attr1' from a resource block. ```bash cat tmp/attr.hcl | hcledit attribute rm resource.foo.bar.attr1 ``` -------------------------------- ### hcledit block append example Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Appends a new nested block to an existing block. ```bash $ cat tmp/block.hcl | hcledit block append resource.foo.bar block1.label1 --newline resource "foo" "bar" { attr1 = "val1" block1 "label1" { } } resource "foo" "baz" { attr1 = "val2" } ``` -------------------------------- ### Set an attribute value Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This example shows how to set a new value for the nested attribute 'attr2' in an HCL file. ```bash cat tmp/attr.hcl | hcledit attribute set resource.foo.bar.nested.attr2 '"val3"' ``` -------------------------------- ### Move (rename) an attribute Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This example demonstrates renaming an attribute from 'attr2' to 'attr3' within a nested block. ```bash cat tmp/attr.hcl | hcledit attribute mv resource.foo.bar.nested.attr2 resource.foo.bar.nested.attr3 ``` -------------------------------- ### Append an attribute with newline Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This example shows how to append a new attribute 'attr3' with a newline character to a nested block. ```bash cat tmp/attr.hcl | hcledit attribute append resource.foo.bar.nested.attr3 '"val3"' --newline ``` -------------------------------- ### hcledit fmt --help Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Help output for the 'hcledit fmt' command, showing its purpose and flags. ```bash $ hcledit fmt --help Format a file to a caconical style Usage: hcledit fmt [flags] Flags: -h, --help help for fmt Global Flags: -f, --file string A path of input file (default "-") -u, --update Update files in-place ``` -------------------------------- ### hcledit body --help Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Help output for the 'hcledit body' command, showing available subcommands and flags. ```bash $ hcledit body --help Edit body Usage: hcledit body [flags] hcledit body [command] Available Commands: get Get body Flags: -h, --help help for body Global Flags: -f, --file string A path of input file (default "-") -u, --update Update files in-place Use "hcledit body [command] --help" for more information about a command. ``` -------------------------------- ### hcledit block --help Source: https://github.com/minamijoyo/hcledit/blob/master/README.md Help output for the 'hcledit block' command, showing available subcommands and flags. ```bash $ hcledit block --help Edit block Usage: hcledit block [flags] hcledit block [command] Available Commands: append Append block get Get block list List block mv Move block (Rename block type and labels) new Create a new block rm Remove block Flags: -h, --help help for block Global Flags: -f, --file string A path of input file (default "-") -u, --update Update files in-place Use "hcledit block [command] --help" for more information about a command. ``` -------------------------------- ### hcledit help command Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This shows the main help message for the hcledit CLI, listing available commands and global flags. ```bash hcledit --help ``` -------------------------------- ### hcledit attribute help command Source: https://github.com/minamijoyo/hcledit/blob/master/README.md This displays the help message for the 'attribute' subcommand, detailing its available operations and flags. ```bash hcledit attribute --help ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.