davidchalifoux/kaput-cli

Support for JSON output?

Closed this issue · 4 comments

It'd be great if there could be a --json or --output json option that outputs a single json record per line, for the files and transfers commands that output a table.

Good idea! Just to clarify, do you want it to output JSON to stdout or to a file?

stdout is great. requiring a file name prevents using stdout, whereas without it, the user still can write to a file.

typically, a list can be produced as a valid json array ([{...},{...},{...}]) or a list of json objects one-per-line ({...}\n{...}\n{...}\n).

I personally prefer the latter. One could make it an option, but there are tools for manipulating JSON like jq that will always have more features, so why not just tell people to use jq to convert or modify the output JSON?

Paul

I've added this in commit e8fb214.

Passing the --json flag will output in pure JSON. I've also tested it with jq and it works nicely!
The output it gives is all of the data that is returned by the API. Was this the extra metadata you were looking for?

Also added the flag to transfers: a61b5aa