Skip to content
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

Output formats #98

Open
tonyfosterdev opened this issue Nov 14, 2021 · 4 comments
Open

Output formats #98

tonyfosterdev opened this issue Nov 14, 2021 · 4 comments

Comments

@tonyfosterdev
Copy link
Contributor

It would be cool to enable various format options for output. We could call the current format "human", but json would be cool too.

Kubectl supports this with the -o flag.

The main use case here would be to allow for scripting support in conjunction with tools like jq.

@gunnarmorling
Copy link
Collaborator

Great idea!

@jornh
Copy link

jornh commented Dec 14, 2021

@tonyfosterdev at least for the describe command as a workaround you can use yq to convert to json - as the format you call "human" is actually yaml.

There is one caveat though. The yaml has color codes in some places which yq chokes on. To get past that we need another workaround and use sed to strip that out. The end result:

kcctl describe connector http3 | sed 's/\x1b\[[0-9;]*m//g' | yq eval -o json

Update: https://picocli.info/#_heuristics_for_enabling_ansi (in particular point 7.) looks helpful if we want to get rid of the sed workaround.

@gunnarmorling
Copy link
Collaborator

That's an interesting observation, @jornh. Note that the YAML output for describe is mostly incidental though, it was not a conscious decision and we may derive from this being YAML in some cases.

@juanlucruz
Copy link

I am lacking this issue exactly. I've tried with the workaround using yq but it's not working for me. Thanks anyway for the wonderful tool Gunnar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants