Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HCL formatting to work with stdin and stdout #2926

Closed
denis256 opened this issue Feb 1, 2024 · 4 comments · May be fixed by #3288
Closed

Improve HCL formatting to work with stdin and stdout #2926

denis256 opened this issue Feb 1, 2024 · 4 comments · May be fixed by #3288
Labels
enhancement New feature or request stale Stale

Comments

@denis256
Copy link
Member

denis256 commented Feb 1, 2024

Describe the solution you'd like
Improve Terragrunt hclfmt command to work with stdin and stdout to make Terragrunt easier to integrate into auto-formatting invocations from IDEs

Describe alternatives you've considered
Used script which read stdin, save in a temp file, format file, write to stdout...

Additional context
Add any other context or screenshots about the feature request here.

@denis256 denis256 added the enhancement New feature or request label Feb 1, 2024
@chinyongcy
Copy link

Need this to work with zed as well

@caseycs
Copy link

caseycs commented Jun 1, 2024

In the meantime simple wrapper bash script can help:

#!/bin/sh
# wrapper to format hcl passed via stdin
# user for for VSCcode Custom Local Formatters extension (https://marketplace.visualstudio.com/items?itemName=jkillian.custom-local-formatters)
# or any other editor relying on stdin/stdout for formatting, like Zed
# relevant issues:
# * https://github.com/gruntwork-io/terragrunt/issues/1037
# * https://github.com/gruntwork-io/terragrunt/issues/2926
TMPFILE=$(mktemp)
cat - > $TMPFILE
terragrunt hclfmt --terragrunt-hclfmt-file $TMPFILE
cat $TMPFILE
rm $TMPFILE

@chinyongcy
Copy link

In the meantime simple wrapper bash script can help:

#!/bin/sh

# wrapper to format hcl passed via stdin

# user for for VSCcode Custom Local Formatters extension (https://marketplace.visualstudio.com/items?itemName=jkillian.custom-local-formatters)

# or any other editor relying on stdin/stdout for formatting, like Zed

# relevant issues:

# * https://github.com/gruntwork-io/terragrunt/issues/1037

# * https://github.com/gruntwork-io/terragrunt/issues/2926

TMPFILE=$(mktemp)

cat - > $TMPFILE

terragrunt hclfmt --terragrunt-hclfmt-file $TMPFILE

cat $TMPFILE

rm $TMPFILE

This is perfect, thank you!

alikhil added a commit to alikhil/terragrunt that referenced this issue Jul 23, 2024
Copy link

github-actions bot commented Sep 1, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.

@github-actions github-actions bot added the stale Stale label Sep 1, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants