Files
Olares/cli/cmd/ctl/osinfo/main.go
eball cd6d502f4a cli: add a command of olares-cli to show full system info (#1658)
* feat: add show all info

* fix: add a wsl info

* Update main.go
2025-07-31 22:32:40 +08:00

56 lines
1.2 KiB
Go

package osinfo
import (
"fmt"
"github.com/beclab/Olares/cli/pkg/common"
"github.com/beclab/Olares/cli/pkg/core/connector"
"github.com/spf13/cobra"
)
func NewCmdInfo() *cobra.Command {
infoCmd := &cobra.Command{
Use: "osinfo",
Short: "Print system information, etc.",
Long: "help for printing info",
}
infoCmd.AddCommand(showInfoCommand())
infoCmd.AddCommand(showAllCommand())
return infoCmd
}
func showInfoCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "show",
Short: "Print os information",
Long: "help for printing os info",
Run: func(cmd *cobra.Command, args []string) {
systemInfo := connector.GetSystemInfo()
host := systemInfo.HostInfo
fmt.Printf(`OS_TYPE=%s
OS_PLATFORM=%s
OS_ARCH=%s
OS_VERSION=%s
OS_KERNEL=%s
OS_INFO=%s
`, host.OsType, host.OsPlatformFamily, host.OsArch, host.OsVersion, host.OsKernel, host.OsInfo)
},
}
return cmd
}
func showAllCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "showall",
Short: "Print full os information",
Long: "help for printing os info",
Run: func(cmd *cobra.Command, args []string) {
arg := common.NewArgument()
arg.SystemInfo.Print()
},
}
return cmd
}