chrly/cmd/version.go

33 lines
658 B
Go
Raw Normal View History

package cmd
import (
"fmt"
"os"
2020-01-03 03:21:57 +05:30
"runtime"
"github.com/spf13/cobra"
2020-01-03 03:21:57 +05:30
"github.com/elyby/chrly/version"
)
var versionCmd = &cobra.Command{
Use: "version",
2018-02-15 02:19:22 +05:30
Short: "Show the Chrly version information",
Run: func(cmd *cobra.Command, args []string) {
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())
fmt.Printf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
fmt.Printf("Hostname: %s\n", hostname)
},
}
func init() {
RootCmd.AddCommand(versionCmd)
}