Skip to content

Commit

Permalink
Merge pull request #7 from uitml/version-command
Browse files Browse the repository at this point in the history
Add version command
  • Loading branch information
thomasjo authored Jul 20, 2020
2 parents 10dfc93 + 17ad1c6 commit bdec0bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ builds:
- linux
goarch:
- amd64
ldflags:
- -s -w -X github.com/uitml/frink/cmd.version={{ .Version }} -X github.com/uitml/frink/cmd.commit={{ .ShortCommit }} -X github.com/uitml/frink/cmd.date={{ .Date }}

archives:
- format: binary
Expand Down
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 (
"fmt"

"github.com/spf13/cobra"
)

var (
version string
commit string
date string
)

var versionCmd = &cobra.Command{
Use: "version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("frink v%s\n", version)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}
6 changes: 0 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import (
"github.com/uitml/frink/cmd"
)

var (
version string
commit string
date string
)

func main() {
cmd.Execute()
}

0 comments on commit bdec0bb

Please sign in to comment.