Skip to content

Commit

Permalink
Add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert221 committed Nov 17, 2022
1 parent ea02d66 commit 4bb57de
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
builds:
- targets:
-
targets:
- linux_amd64
- windows_amd64
- darwin_amd64
- darwin_arm64
ldflags:
- >
-s -w
-X github.com/leancodepl/poe2arb/cmd.Version={{.Version}}
-X github.com/leancodepl/poe2arb/cmd.Commit={{.Commit}}
-X github.com/leancodepl/poe2arb/cmd.BuiltDate={{.Date}}
universal_binaries:
- replace: true
changelog:
Expand Down
1 change: 1 addition & 0 deletions cmd/poe2arb.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var rootCmd = &cobra.Command{
func Execute() {
rootCmd.AddCommand(convertCmd)
rootCmd.AddCommand(poeCmd)
rootCmd.AddCommand(versionCmd)

rootCmd.Execute()
}
24 changes: 24 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import "github.com/spf13/cobra"

var (
// Version is the version of the application. It is set during the build process using ldflags.
Version = "dev"
// Commit is the commit hash of the application. It is set during the build process using ldflags.
Commit = "none"
// Date is the date of the build. It is set during the build process using ldflags.
BuiltDate = "unknown"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of poe2arb",
RunE: runVersion,
}

func runVersion(cmd *cobra.Command, args []string) error {
cmd.Printf("poe2arb version %s, commit %s, built at %s\n", Version, Commit, BuiltDate)

return nil
}

0 comments on commit 4bb57de

Please sign in to comment.