TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: JSON Output for CLI Tools?

3 pointsby zeisssalmost 5 years ago
I am currently our public command-line tool some love and although we officially have an `--output=json` flag, it rarely works or does anything useful.<p>* While thinking about how to fix&#x2F;implement this for more commands I was wondering if this kind of more structured output is actually of interest&#x2F;use for developers&#x2F;devops&#x2F;SRE?<p>Some context: The tool in question is a client for our API and used for validation + updating resources and triggering long running loadtest jobs. Users are developers, although we also recommend it for integration into CI&#x2F;CD pipelines etc.<p>Any feedback is welcome :)

3 comments

mikecealmost 5 years ago
If the idea is to have output from CLI apps&#x2F;scripts that can be easily parsed so that chaining scripts together without regexing yourself to death is the goal this sounds like what PowerShell Core (which runs on macOS and Linux as well) does: PS commands return objects -- with a default .ToString() output if you don&#x27;t grab the result and use it in the next step&#x2F;script -- allowing easy object.property accessors as well as foreach iteration if the command returns a list&#x2F;array of objects.
评论 #24081467 未加载
maerF0x0almost 5 years ago
I find json output massively valuable because I combine it with `jq` instead of having to try and cut (or other command) slice up responses.
viraptoralmost 5 years ago
If your json-vs-text output drifts often, you could make the backing objects the same. AWS kind of does it in their cli tool. It&#x27;s all objects and json inside, but you see nicely rendered tables. &quot;--output=json&quot; gives you the real&#x2F;raw data.