Skip to content

Commit

Permalink
feat: added version info (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufhm authored Jun 21, 2022
1 parent 956722f commit bd5f8c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
"github.com/spf13/cobra"
)

// Version information.
var (
Version string
Commit string
)

var rootCmd = &cobra.Command{
Use: "rockpool [command]",
Short: "Easily create local Lagoon instances.",
Expand All @@ -21,6 +27,15 @@ var rootCmd = &cobra.Command{
},
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Displays the application version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Version: ", Version)
fmt.Println("Commit: ", Commit)
},
}

var upCmd = &cobra.Command{
Use: "up [name...]",
Short: "Create and/or start the clusters",
Expand Down Expand Up @@ -105,6 +120,7 @@ subdomains using the provided 'name', e.g, rockpool.k3d.local, lagoon.rockpool.k
to use ~/.ssh/id_ed25519.pub first, then ~/.ssh/id_rsa.pub.
`)

rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(upCmd)
rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(stopCmd)
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import (
"github.com/salsadigitalauorg/rockpool/cmd"
)

// Version information.
var (
version string
commit string
)

func main() {
cmd.Version = version
cmd.Commit = commit
cmd.Execute()
}

0 comments on commit bd5f8c8

Please sign in to comment.