-
Notifications
You must be signed in to change notification settings - Fork 494
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
feat: Add support for the JSONC format #2827
Conversation
GitHub Markdown itself as well ```jsonc: {
// comment and trailing comma
"test": true,
} |
Deno also accepts https://deno.land/[email protected]/getting_started/configuration_file |
I think that adding |
Thanks for the super-fast testing and feedback! So we need two things:
Obviously, as there is no official standard here, there is no right answer, only a least-bad answer. The argument "do what VSCode does" is a very strong one as this is what most developers use these days. So, is the following reasonable?
Thoughts? |
This is very reasonable to me, although, I believe it would be nice to mention somewhere in the docs which Go library is used to parse JSONC (which would be the closest thing to a reference for a specification IMO). |
Actually I tested it only now, but it is working great: ❯ printf "%s\n" "{" " // This is a comment" ' "a": "whatever",' "}" | /mnt/c/Users/felip/Downloads/chezmoi-linux-amd64/chezmoi execute-template --with-stdin '{{ fromJson .chezmoi.stdin | toPrettyJson }}'
null
❯ printf "%s\n" "{" " // This is a comment" ' "a": "whatever",' "}" | /mnt/c/Users/felip/Downloads/chezmoi-linux-amd64/chezmoi execute-template --with-stdin '{{ fromJwcc .chezmoi.stdin | toPrettyJson }}'
{
"a": "whatever"
} |
pkg/chezmoi/format.go
Outdated
"toml": FormatTOML, | ||
"yaml": FormatYAML, | ||
"yml": FormatYAML, | ||
"hujson": FormatJSONC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's still worth supporting this hujson
extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point, removed extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it would be nice to mention somewhere in the docs which Go library is used to parse JSONC
Good point. I added a link in the fromJsonc
doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, as everything about chezmoi.
Fixes #2825.
@felipecrs can you test this?