cli icon indicating copy to clipboard operation
cli copied to clipboard

Add option for JSON output to (specific) CLI commands

Open hslatman opened this issue 2 years ago • 2 comments

What would you like to be added

Add a flag (e.g. --json) to make the CLI print its output in JSON format.

Why this is needed

Supporting JSON output provides for easier composability of command invocations. The CLI could be used with jq, for example, to filter or extract certain parts from the output.

Some things to take into account:

  • Some commands already print JSON by default
  • Error cases should be handled nicely (i.e. exit codes vs. printed errors)
  • Calling the APIs directly is of course also an option
  • ...

Also see: https://github.com/smallstep/cli/pull/512#discussion_r697624239, which was the reason for creating the issue.

hslatman avatar Sep 16 '21 22:09 hslatman

Can you provide a list of some of these commands?

maraino avatar Sep 17 '21 20:09 maraino

As of now:

  • EAB management (acme eab list|add|remove|get)

In general, output could be made more friendly to being piped into other tools for further processing.

hslatman avatar Mar 09 '22 10:03 hslatman