From 9d58571a630c18b41d77cedad3aac43b600d8d55 Mon Sep 17 00:00:00 2001 From: John Bryan Sazon Date: Wed, 2 May 2018 19:44:14 +0800 Subject: [PATCH] Add version flag --- cmd/root.go | 4 ++++ cmd/version.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 cmd/version.go diff --git a/cmd/root.go b/cmd/root.go index 76bb0af..354e908 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -35,6 +35,10 @@ var srcFile, destDir string var rootCmd = &cobra.Command{ Use: "gota", Short: "Go Over the Air installation for Android APK and iOS Ipa files!", + Run: func(cmd *cobra.Command, args []string) { + cmd.SetVersionTemplate("v0.1.4") + }, + Version: getVersion(), } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..cdad51e --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,12 @@ +package cmd + +import ( + "fmt" + "runtime" +) + +const version = "v0.1.4" + +func getVersion() string { + return fmt.Sprintf("%s %s/%s", version, runtime.GOOS, runtime.GOARCH) +}