Skip to content

Commit 8ae3610

Browse files
authored
feat: add version number
1 parent 76d1b69 commit 8ae3610

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cmd/root.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"os/exec"
78
"path/filepath"
@@ -15,6 +16,16 @@ import (
1516

1617
var config = cfg.Default()
1718

19+
const (
20+
versionFmt = "%s (%s %s)"
21+
)
22+
23+
var (
24+
version = "dev"
25+
commit = "none"
26+
date = "unknown"
27+
)
28+
1829
func init() {
1930
RootCmd.AddCommand(InitCmd)
2031
RootCmd.AddCommand(ValidateCmd)
@@ -36,6 +47,7 @@ var RootCmd = &cobra.Command{
3647
RunE: func(cmd *cobra.Command, args []string) error {
3748
return runRoot(cmd.Context())
3849
},
50+
Version: fmt.Sprintf(versionFmt, version, commit, date),
3951
}
4052

4153
func runRoot(ctx context.Context) error {

0 commit comments

Comments
 (0)