From ee7979324415a65217d43151de03883cb1094c40 Mon Sep 17 00:00:00 2001 From: abdullahnettoor Date: Tue, 29 Oct 2024 13:39:04 +0530 Subject: [PATCH] feat: add version command and initial version. - Add a `version` command to print the current version of the application. - Set the initial version to `v0.1.0`. Signed-off-by: abdullahnettoor --- cmd/version.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 cmd/version.go diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..ec501d7 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,29 @@ +/* +Copyright © 2024 Abdullah Nettoor abdullahnettoor@gmail.com +*/ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var ( + // Version holds the current version of the application + Version = "v0.1.0" +) + +// versionCmd represents the version command +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the version number of TicTacToe", + Long: `All software has versions. This is TicTacToe's.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("TicTacToe %s\n", Version) + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +}