-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: --format=json #7
Conversation
@@ -33,6 +34,7 @@ type cli struct { | |||
|
|||
verbose bool | |||
tenant string | |||
format string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to use display.OutputFormat
here directly (instead of string) but I didn't know how to make it work case insensitive
@@ -96,9 +98,17 @@ func (c *cli) init() error { | |||
c.tenant = c.data.DefaultTenant | |||
} | |||
|
|||
format := strings.ToLower(c.format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json, JSON it should work for the user
MessageWriter: os.Stderr, | ||
ResultWriter: os.Stdout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intermediate messages use Stderr to keep the stdout clean for the final result (json or not), this way the output can be piped to another command (like jq
)
} | ||
|
||
func (r *Renderer) Table(header []string, data [][]string) { | ||
func writeTable(w io.Writer, header []string, data [][]string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private now in favor of .Result(). The cli setup will know when to render as table, or json, YAML, etc
res = append(res, &clientView{ | ||
Name: auth0.StringValue(c.Name), | ||
Type: appTypeFor(c.AppType), | ||
ClientID: auth0.StringValue(c.ClientID), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if for JSON we just dumped the whole object? let users do whatever filtering/processing/formatting they need with jq
or similar? There's a lot of info there it could be really useful to have (https://github.com/go-auth0/auth0/blob/master/management/client.go#L3)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of having --full
or --deep
mode. not completely sure if the format should also imply the level of details. As a user, I would expect the same columns and transformations (like appTypeFor()
) instead of having the internals exposed, makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imagine if this command includes everything available here 😅: https://docs.github.com/en/rest/reference/pulls#list-pull-request
❯ gh pr list --state closed
Showing 17 of 17 pull requests in auth0/pkg that match your search
#17 This bumps go-instrumentation to 0.3.2 which bumps sentry to 0.0.9 sentry-v0.0.9-bump
#16 Bumping lightstep tracer to 0.23.0 bump-lightstep-tracer-to-0.23.0
#15 loggertest: ExpectLogged now takes in a proto.Message change-expect-log-to-use-proto
#14 Log the Addr to which the http server binds log-bound-addr
#13 Bump datadag to 4.2.0 bump-datadog-to-4-2-0
#12 Add error reporter via sentry add-error-reporter-via-sentry
#11 Add secretbox with aes+gcm implementation add-crypto-aes-gcm-package
#10 Setup CI with Jenkins jenkins
#9 Update version of statds library, with fixed typo for With{out}AggregationInterval ja30278:master
#8 Use auth0/go-instrumentation for logging go-instrumentation
#7 Support defining a namespace for service metrics support-metric-namespace
#6 Add Timing to metrics interface add-timing-to-interface
#5 Add Timing to metrics timing
#4 Adds lightstep tracer add-tracer
#3 enable client side aggregation use-client-side-aggregation
#2 service: extract standard service concept extract-service-concept
#1 Add github actions add-github-actions-ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for text mode it makes sense to curate what the user sees, but for JSON mode it's likely just being piped to something else and the full object probably makes more sense IMO.
But in any case, absolutely not a blocker and can be discussed (bikeshedded 😆) later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is a pretty valid point, eventually we'll need to show more details. we can go back to this as we move on with the commands 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
type View interface { | ||
AsTableHeader() []string | ||
AsTableRow() []string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I partially agree with @paddycarey regarding full results eventually. For the purposes of this PR, let's keep it as it is.
The only change I think we need to do in the future is maybe:
- Make
View
have aRaw interface{}
which we can dump the entire SDK's response to. - For the
JSON
format, we just use theRaw
instead of theView
directly.
Either way great progress!
@jfatta took the liberty to rebase and fix the breakage with the logs stuff expecting a |
Awesome, thanks |
Add support for
--format=json
go run ./cmd/auth0 clients list --format=json | jq