hq
hq
is a command-line HCL processor.
install
This will install an hq
binary on your system:
usage
Here is an example HCL file:
some_attr = {
foo = [1, 2]
bar = true
}
some_block "some_block_label" {
attr = "value"
}
some_block "another_block_label" {
attr = "another_value"
}
You can query the attribute(s) and block(s) in an HCL file like so:
|
{
foo = [
1,
2
]
bar = true
}
|
[
1,
2
]
|
some_block "some_block_label" {
attr = "value"
}
some_block "another_block_label" {
attr = "another_value"
}
|
"value"
|
"another_value"
Or read directly from a file by passing read -f
:
some_block "some_block_label" {
attr = "value"
}
some_block "another_block_label" {
attr = "another_value"
}
You can modify HCL (even HCL that is formatted and contains comments) like so:
|
some_attr = {
foo = [1, 2]
bar = true
}
some_block "some_block_label" {
attr = "value"
}
some_block "another_block_label" {
attr = "another_value"
}
# this is a block comment
fmt_block "fmt_label" {
# this is a body comment
# this is another body comment
# this is a third body comment
first_formatted_field = "something_new"
second_formatted_field = "second_value"
}
nested_block {
inner_block {
value = "deep"
another_value = "nested"
}
}
Modifications can also be written directly to a file by passing -i
/--inline
and -f
/--file
:
You can delete entries in an HCL file like so:
|
some_attr = {
foo = [1, 2]
bar = true
}
some_block "some_block_label" {
attr = "value"
}
some_block "another_block_label" {
attr = "another_value"
}
# this is a block comment
fmt_block "fmt_label" {
# this is a body comment
# this is another body comment
# this is a third body comment
first_formatted_field = "fmt_value"
second_formatted_field = "second_value"
}
nested_block {
inner_block {
another_value = "nested"
}
}
Or you can delete entries from a file by passing -i
/--inline
and -f
/--file
: