update at 2019-10-03 10:27:40 by ehlxr

master
ehlxr 2019-10-03 10:27:40 +08:00
parent 635ac4a230
commit ae6164c0ff
2 changed files with 9 additions and 3 deletions

View File

@ -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)

View File

@ -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)
}