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

Support --version flag #105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ builds:
- arm64
- arm
- 386
ldflags:
- -s -w -X go.mercari.io/yo/cmd.version={{.Version}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Default is -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser.

https://goreleaser.com/customization/build/

ignore:
- goos: darwin
goarch: 386
Expand Down
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
`
)

var version = "dev"

var (
rootOpts = internal.ArgType{}
rootCmd = &cobra.Command{
Expand Down Expand Up @@ -103,6 +105,7 @@ var (
},
SilenceUsage: true,
SilenceErrors: true,
Version: version,
}
)

Expand Down
3 changes: 3 additions & 0 deletions v2/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const (
`
)

var version = "dev"

var (
rootCmd = &cobra.Command{
Use: "yo",
Expand All @@ -47,6 +49,7 @@ var (
RunE: nil,
SilenceUsage: true,
SilenceErrors: true,
Version: version,
}
)

Expand Down