diff --git a/cmd/ots-cli/cmd_version.go b/cmd/ots-cli/cmd_version.go new file mode 100644 index 0000000..313423f --- /dev/null +++ b/cmd/ots-cli/cmd_version.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Displays the tool version", + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("ots-cli %s\n", version) //nolint:forbidigo + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +} diff --git a/cmd/ots-cli/main.go b/cmd/ots-cli/main.go index 068527e..c7801ea 100644 --- a/cmd/ots-cli/main.go +++ b/cmd/ots-cli/main.go @@ -4,6 +4,8 @@ import ( "os" ) +var version = "dev" + func main() { if err := rootCmd.Execute(); err != nil { os.Exit(1)