2017-09-11 16:46:25 +05:30
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-04-23 23:40:42 +05:30
|
|
|
"os"
|
2020-01-03 03:21:57 +05:30
|
|
|
"runtime"
|
2017-09-11 16:46:25 +05:30
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2020-01-03 03:21:57 +05:30
|
|
|
|
|
|
|
"github.com/elyby/chrly/version"
|
2017-09-11 16:46:25 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
var versionCmd = &cobra.Command{
|
|
|
|
Use: "version",
|
2018-02-15 02:19:22 +05:30
|
|
|
Short: "Show the Chrly version information",
|
2017-09-11 16:46:25 +05:30
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2020-04-23 23:40:42 +05:30
|
|
|
hostname, err := os.Hostname()
|
|
|
|
if err != nil {
|
|
|
|
hostname = "<unknown>"
|
|
|
|
}
|
|
|
|
|
2020-01-03 03:21:57 +05:30
|
|
|
fmt.Printf("Version: %s\n", version.Version())
|
|
|
|
fmt.Printf("Commit: %s\n", version.Commit())
|
|
|
|
fmt.Printf("Go version: %s\n", runtime.Version())
|
2017-09-11 16:46:25 +05:30
|
|
|
fmt.Printf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
2020-04-23 23:40:42 +05:30
|
|
|
fmt.Printf("Hostname: %s\n", hostname)
|
2017-09-11 16:46:25 +05:30
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RootCmd.AddCommand(versionCmd)
|
|
|
|
}
|