Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 10 commits intomainfromcj/version-json
Apr 5, 2023

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedApr 5, 2023
edited
Loading

$ build/coder-slim_$(./scripts/version.sh)_linux_amd64 version --output=textCoder v0.21.3-devel+b099e5c58 Wed Apr  5 12:03:29 UTC 2023https://github.com/coder/coder/commit/b099e5c58c9f8dbb2fbbded3d559da7923cab3f8Slim build of Coder, does not support the  server  subcommand.$ build/coder-slim_$(./scripts/version.sh)_linux_amd64 version --output=json{  "version": "v0.21.3-devel+b099e5c58",  "build_time": "2023-04-05T12:03:29Z",  "external_url": "https://github.com/coder/coder/commit/b099e5c58c9f8dbb2fbbded3d559da7923cab3f8",  "slim": true,  "agpl": false}

@johnstcnjohnstcn self-assigned thisApr 5, 2023
@johnstcnjohnstcn marked this pull request as ready for reviewApril 5, 2023 10:57
Copy link
Member

@mtojekmtojek left a 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

err := inv.WithContext(ctx).Run()
require.NoError(t, err)
actual := buf.String()
actual = strings.Replace(actual, "\r\n", "\n", -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: ReplaceAll?

johnstcn reacted with thumbs up emoji
// version prints the coder version
func (*RootCmd) version() *clibase.Cmd {
handleHuman := func(inv *clibase.Invocation) error {
var str strings.Builder
Copy link
Member

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?

Copy link
MemberAuthor

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.

mtojek reacted with thumbs up emoji
@mafredri
Copy link
Member

Hmm, should we call the flag output/format to align with table formatter and potentially support other formats in the future?

@johnstcn
Copy link
MemberAuthor

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)

@mafredri
Copy link
Member

mafredri commentedApr 5, 2023
edited
Loading

Good point, we should have a consistent naming (although the current format is decidedly un-tabular)

Yeah, using a clibase enum with onlyjson seems sufficient here, only allowing-{o,-output} json (or maybe json and text, default being text). But users being able to rely on the--output flag seems like a good idea.

@johnstcn
Copy link
MemberAuthor

Good point, we should have a consistent naming (although the current format is decidedly un-tabular)

Yeah, using a clibase enum with onlyjson seems sufficient here, only allowing-{o,-output} json (or maybe json and text, default being text). But users being able to rely on the--output flag seems like a good idea.

Turns out I needed to add atextFormat option tocli/cliui which wasn't too bad. It also forced me to somewhat abstract where we get the version info from, which isn't a bad thing. I haven't figured out how to plumb random version info into the unit tests yet, but that's a good follow-on PR.

@johnstcnjohnstcn changed the titlefeat(cli): add --json output to version cmdfeat(cli): add --output={text,json} to version cmdApr 5, 2023
@johnstcnjohnstcn merged commit00d468b intomainApr 5, 2023
@johnstcnjohnstcn deleted the cj/version-json branchApril 5, 2023 12:16
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 5, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@mafredrimafredrimafredri approved these changes

@mtojekmtojekmtojek approved these changes

Assignees

@johnstcnjohnstcn

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@johnstcn@mafredri@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp