-
-
Notifications
You must be signed in to change notification settings - Fork 120
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 --indent option to CLI tool #559
Conversation
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 have two concerns with this change:
-
Could you clarify what's the use case of pretty-printed JSON output? For single-shot manual use, wouldn't the same be served by piping the output to a separate JSON prettifier like
jq
? -
Naming the option as "pretty" and only affecting the JSON output seems rather misleading. Either the option needs to make sense independently of
--json
, or it needs to be named more specifically.
Non single-shot manual use… Like in Moreover, I want to do a PR for Forcing this to be inflexible, and add an extra dependency just to make JSON output readable, adding friction to adoption for the sake of basically a single line of code—in fact just a single parameter to an existing builtin function—seems silly…
I had a similar thought, but there is no such thing as I think the ideal API would be an optional parameter, maybe to This is the yaml.js API, for reference. |
Eh, not sure that it really makes sense to prettify output that's meant for machine consumption, as it risks creating JSON files that will be presumed to be the source of truth, rather than intermediate build assets. But I'll grant you that there's probably a valid use case somewhere here.
|
Well the YAML files are the source… But a lot of tools only work from JSON. Harder to debug if it has to be minified also…
Good idea, will look into it… |
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.
Overall the API looks good, see inline for implementation changes.
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.
Thank you, this looks good! Sorry for the delay in getting to this. There was a missing newline from the test source, which I added to get the test to pass.
No worries, life gets in the way… I know! |
Add a
--indent
option, to be used with--json
to output 2 space indentation.See also #479 and #523.