add version

Signed-off-by: Lei Xue <vfs@live.com>
This commit is contained in:
Lei Xue
2020-07-14 22:04:20 +08:00
parent db3093d24b
commit 2e5cea1bd0
3 changed files with 48 additions and 6 deletions

View File

@@ -1,11 +1,10 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/gostor/gotgt/pkg/api/client"
"github.com/gostor/gotgt/pkg/version"
"github.com/spf13/cobra"
)
func newVersionCommand(cli *client.Client) *cobra.Command {
@@ -14,7 +13,7 @@ func newVersionCommand(cli *client.Client) *cobra.Command {
Short: "Print the version number of gotgt",
Long: `All software has versions. This is Gotgt 's`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Gotgt %s -- HEAD\n", version.Version)
version.PrintVersionAndExit()
},
}
return cmd