Skip to content

Commit 3a69afc

Browse files
authored
Merge pull request #10 from DerZersaeger/master
Use "--version" to show the version
2 parents 53bad72 + a19c2ce commit 3a69afc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/cli/cmd/root.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ var rootCmdOptions struct {
2424
var logger kitlog.Logger
2525

2626
var rootCmd = &cobra.Command{
27-
Use: "glow",
28-
Short: "small tool to adapt git-flow for gitlab",
27+
Use: "glow",
28+
Short: "small tool to adapt git-flow for gitlab",
29+
Version: "0.0.0", // needed to set the version dynamically
2930
PersistentPreRun: func(cmd *cobra.Command, args []string) {
3031
if rootCmdOptions.CICDOrigin != "" {
3132
g, err := util.GetGitClient()
@@ -35,17 +36,16 @@ var rootCmd = &cobra.Command{
3536
util.CheckForError(err, "SetCICDOrigin")
3637
}
3738
},
38-
Run: func(cmd *cobra.Command, args []string) {
39-
box := packr.NewBox("../../../buildAssets")
40-
version, err := box.FindString("VERSION")
41-
if err != nil {
42-
log.Fatal(err)
43-
}
44-
fmt.Printf("Version of glow: %s\n", version)
45-
},
4639
}
4740

4841
func init() {
42+
box := packr.NewBox("../../../buildAssets")
43+
version, err := box.FindString("VERSION")
44+
if err != nil {
45+
log.Fatal(err)
46+
}
47+
rootCmd.SetVersionTemplate(version)
48+
4949
rootCmd.PersistentFlags().StringVarP(&rootCmdOptions.Author, "author", "a", "", "name of the author")
5050
rootCmd.PersistentFlags().StringVar(&rootCmdOptions.GitPath, "gitPath", "/usr/local/bin/git", "path to native git installation")
5151
rootCmd.PersistentFlags().BoolVar(&rootCmdOptions.UseBuiltInGitBindings, "useBuiltInGitBindings", false, "defines wether build or native in git client should be used.")

0 commit comments

Comments
 (0)