From 2690f1148852043b5822acd8819b641a426a3fca Mon Sep 17 00:00:00 2001 From: jichangjun Date: Fri, 3 Jul 2020 19:30:08 +0800 Subject: [PATCH] goc command: version --- cmd/version.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cmd/version.go diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..833f772 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,42 @@ +/* + Copyright 2020 Qiniu Cloud (qiniu.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// the version value will be injected when publishing +var version = "Unstable" + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the goc version information", + Example: ` +# Print the client and server versions for the current context +goc version + `, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(version) + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +}