Skip to content

Commit

Permalink
feat: added version command
Browse files Browse the repository at this point in the history
  • Loading branch information
lindell committed Jun 30, 2020
1 parent 087b404 commit 109e158
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func init() {
RootCmd.AddCommand(RunCmd)
RootCmd.AddCommand(StatusCmd)
RootCmd.AddCommand(MergeCmd)
RootCmd.AddCommand(VersionCmd)

rand.Seed(time.Now().UTC().UnixNano())
}
Expand Down
23 changes: 23 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// VersionCmd prints the version of multi-gitter
var VersionCmd = &cobra.Command{
Use: "version",
Short: "Get the version of multi-gitter.",
Long: "Get the version of multi-gitter.",
Args: cobra.NoArgs,
Run: version,
}

// Version is the current version of multigitter (set by main.go)
var Version string

func version(cmd *cobra.Command, args []string) {
fmt.Println(Version)
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"github.com/lindell/multi-gitter/cmd"
)

var version = "development"

func main() {
cmd.Version = version
if err := cmd.RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down

0 comments on commit 109e158

Please sign in to comment.