From bd5f8c816a87bcbedfc9ec08229b6ef4bc1e3728 Mon Sep 17 00:00:00 2001 From: "Yusuf A. Hasan Miyan" Date: Tue, 21 Jun 2022 15:11:17 +1000 Subject: [PATCH] feat: added version info (#5) --- cmd/root.go | 16 ++++++++++++++++ main.go | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index 3f8064c..3f46eb0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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.", @@ -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", @@ -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) diff --git a/main.go b/main.go index 58a4a02..58e359b 100644 --- a/main.go +++ b/main.go @@ -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() }