mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Resolves #21. Print hostname in the version command output
This commit is contained in:
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -13,10 +14,16 @@ var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Show the Chrly version information",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
hostname = "<unknown>"
|
||||
}
|
||||
|
||||
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)
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user