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

add --with-comments to preserve comments when returning an attribute #103

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

wondersd
Copy link
Contributor

fixes #102

Only returns comments when attribute value is a block. Not sure whats missing to capture inline comments. However for the purposes of the original request this would be close enough

@minamijoyo
Copy link
Owner

Thanks for working on this. Overall, it looks good, but let me point out a few things.

(1) The linter check is failing. Some files need to be formatted.

(2) Although this cannot be strictly checked in the linter, the Go style convention recommends MixedCaps. That is to say, withComments seems more natural than withcomments for local variable names.

(3) Regarding being unable to get inline comments, they may belong to an attribute rather than an expression. I'll look into this later, but is this essential for your use case? I am unsure if I can find the time to look into it right away.

@wondersd
Copy link
Contributor Author

Thanks for looking at this. I was going to go with withComments but everything else in the repo seemed to stick to lower so went with withcomments, will change and fix formatting.

For inline comments it doesn't matter for my purposes, i just considered it for completeness sake. If this goes out as is should we consider --with-comments-on-blocks to not make this a breaking change when inline comments are able to be accounted for?

@minamijoyo
Copy link
Owner

Thank you for the fix! I'll investigate the inline comments issue later, but I believe it would be technically possible without breaking the CLI interface, so there is no need to rename the flag. Let's merge and move forward!

Copy link
Owner

@minamijoyo minamijoyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@minamijoyo minamijoyo merged commit 9bf312f into minamijoyo:master Aug 29, 2024
4 checks passed
@wondersd wondersd deleted the preserve-comments branch August 29, 2024 13:31
@minamijoyo
Copy link
Owner

@wondersd I've shipped it in v0.2.14 🚀 Thank you for your contribution!

minamijoyo added a commit that referenced this pull request Aug 30, 2024
Follow-up to #103.
Inline comments belong to attributes, not expressions. When the
`--with-comments` flag is specified, we need to return tokens on the
right side of the equals sign.
@minamijoyo
Copy link
Owner

@wondersd FYI: I had time to debug the inline comment issue today and finally figured out how to fix it (#104), released in v0.2.15 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow comments to be preserved when using hcledit attribute get
2 participants