Open mkcp opened 2 weeks ago
@rjferguson21 Appreciate the request, let us know what you think and if there's anything you'd like us to add.
Some prior work for ideas:
Vault -format with tables, json, yaml, and jsonx (scroll down to -format
): https://developer.hashicorp.com/vault/docs/commands
k8s jsonpath https://kubernetes.io/docs/reference/kubectl/jsonpath/
GH -json formatting options: https://cli.github.com/manual/gh_help_formatting
Is your feature request related to a problem? Please describe.
With the addition of structured logging #2576 it's become clear that structured data has user value in outputs not just diagnostic logs. Currently most output, like in
zarf package list
is printed using pterm tables.Describe the behavior you'd like
In addition to tables, being able to output json, yaml, or potentially other formats would be hugely valuable for users to script and parse zarf's output. Some utilites like
gh
andvault
provide filtering as well. This allows users to specify only the fields they want in their output, cutting out steps in external tools later. Filtering is more of a nice to have and maybe more appropriate for a second iteration.@Racer159 Raised the detail that
zarf version
has an--output / -o flag
already and supports rendering to json and yaml. That's a good starting point for us extending this behavior into other commands.Additional context
This shouldn't be too difficult to implement because, at least as far as I could tell writing this, all of the table printing is well contained to
cmd
. Swapping out the printer from message, or extracting it into a more configurable layer shouldn't require any significant architecture changes - just pass the data to a new renderer.