bashhub-server/cmd/version.go

52 lines
1.3 KiB
Go
Raw Normal View History

2020-02-10 09:30:10 +08:00
/*
*
2020-02-10 09:30:10 +08:00
* Copyright © 2020 nicksherron <nsherron90@gmail.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.
*
2020-02-10 09:30:10 +08:00
*/
2020-02-07 16:02:18 +08:00
package cmd
import (
"fmt"
2020-02-10 09:30:10 +08:00
"runtime"
2020-02-07 16:02:18 +08:00
"github.com/spf13/cobra"
)
// versionCmd represents the version command
2020-02-10 09:30:10 +08:00
var (
2020-02-10 14:54:50 +08:00
GitCommit string
2020-02-10 09:30:10 +08:00
BuildDate string
Version string
OsArch = fmt.Sprintf("%s %s", runtime.GOOS, runtime.GOARCH)
GoVersion = runtime.Version()
versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number and build info",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Build Date:", BuildDate)
2020-02-10 09:35:45 +08:00
fmt.Println("Git Commit:", GitCommit)
2020-02-10 09:30:10 +08:00
fmt.Println("Version:", Version)
fmt.Println("Go Version:", GoVersion)
fmt.Println("OS / Arch:", OsArch)
},
}
)
2020-02-07 16:02:18 +08:00
func init() {
rootCmd.AddCommand(versionCmd)
}