From ae6164c0ffa8eaf30359ba3a167f8f124aedfb60 Mon Sep 17 00:00:00 2001 From: ehlxr Date: Thu, 3 Oct 2019 10:27:40 +0800 Subject: [PATCH] update at 2019-10-03 10:27:40 by ehlxr --- cmd/server.go | 2 ++ cmd/version.go | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index 6ba5778..22d9f1d 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -40,6 +40,8 @@ var serverCmd = &cobra.Command{ host := cmd.LocalFlags().Lookup("host").Value.String() port, _ := strconv.Atoi(cmd.LocalFlags().Lookup("port").Value.String()) + printVersion() + if err := server.Start(host, port); err != nil { fmt.Println(err) os.Exit(1) diff --git a/cmd/version.go b/cmd/version.go index e80f2ca..6dcbb89 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -30,12 +30,12 @@ import ( ) var versionTpl = `%s - Name: hc Version: %s BuildTime: %s GitCommit: %s GoVersion: %s + ` // versionCmd represents the version command @@ -45,11 +45,15 @@ var versionCmd = &cobra.Command{ Long: ` Print version of jwt`, Run: func(cmd *cobra.Command, args []string) { - banner, _ := base64.StdEncoding.DecodeString(metadata.BannerBase64) - fmt.Printf(versionTpl, banner, metadata.Version, metadata.BuildTime, metadata.GitCommit, metadata.GoVersion) + printVersion() }, } +func printVersion() { + banner, _ := base64.StdEncoding.DecodeString(metadata.BannerBase64) + fmt.Printf(versionTpl, banner, metadata.Version, metadata.BuildTime, metadata.GitCommit, metadata.GoVersion) +} + func init() { rootCmd.AddCommand(versionCmd) }