-
Notifications
You must be signed in to change notification settings - Fork 887
feat(cli): add --output={text,json} to version cmd #7010
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
Conversation
johnstcn
commented
Apr 5, 2023
•
edited
Loading
edited
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.
nit-picks can be ignored
cli/version_test.go
Outdated
err := inv.WithContext(ctx).Run() | ||
require.NoError(t, err) | ||
actual := buf.String() | ||
actual = strings.Replace(actual, "\r\n", "\n", -1) |
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.
nit: ReplaceAll?
cli/version.go
Outdated
// version prints the coder version | ||
func (*RootCmd) version() *clibase.Cmd { | ||
handleHuman := func(inv *clibase.Invocation) error { | ||
var str strings.Builder |
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.
nit: do you need a string builder if there is no way to break execution in the middle of processing?
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.
Not sure, but this is just the previous code I copy-pasta'ed.
Hmm, should we call the flag output/format to align with table formatter and potentially support other formats in the future? |
Good point, we should have a consistent naming (although the current format is decidedly un-tabular) |
Yeah, using a clibase enum with only |
Turns out I needed to add a |