mirror of
https://github.com/nestriness/cli.git
synced 2025-12-11 11:55:35 +02:00
feat: merge main into run
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
:*@@@@@*-
|
||||
+@@@@@@@@@@#=.
|
||||
:@@@@@@@@@@@@@@%+:
|
||||
.:--. .#@@@@:.=*@@@@@@@@@*-
|
||||
-%@@@@@@*-. .=#@. :+#@@@@@@@@#+.
|
||||
*@@@@@@@@@@@%+: .=#@@@@@@@@%=
|
||||
@@@@@@#@@@@@@@@@*-. -*@@@@@@@*
|
||||
@@@@@* :+%@@@@@@@@%+: +@@@@@@
|
||||
@@@@@+ -#@@@@@@@@@*. :+@@@@@@@*
|
||||
@@@@@+ -+%@@@*=. .=*@@@@@@@@%=
|
||||
@@@@@+ :*=. :+%@@@@@@@@#=.
|
||||
@@@@@+ -@@@%- +@@@@@@@@@#-
|
||||
@@@@@+ -@@@@@ @@@@@@%*- -*%%*.
|
||||
@@@@@* -@@@@@: @@@#=. +@@@@@@@=
|
||||
@@@@@* . -@@@@@: +: .+@@@@@@
|
||||
@@@@@#=*%* -@@@@@- :+@@@@@@%
|
||||
%@@@@@@@@+ -@@@@@- .-*@@@@@@@@#.
|
||||
.*@@@@@@@+ -@@@@@- .+%@@@@@@@@%+.
|
||||
.=+**+- :@@@@@= .-*%@@@@@@@@#=.
|
||||
:@@@@@%%@@@@@@@@%+-
|
||||
%@@@@@@@@@@@#=.
|
||||
.+%@@@@@%*-
|
||||
**************************************************
|
||||
##################################################
|
||||
##################################################
|
||||
##################################################
|
||||
##################################################
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
**************************************************
|
||||
##################################################
|
||||
##################################################
|
||||
##################################################
|
||||
##################################################
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
**************************************************
|
||||
##################################################
|
||||
##################################################
|
||||
##################################################
|
||||
##################################################
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
66
cmd/root.go
66
cmd/root.go
@@ -8,6 +8,9 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/nestriness/cli/pkg/specs"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/charmbracelet/lipgloss/table"
|
||||
@@ -19,7 +22,6 @@ import (
|
||||
var art string
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
// For a good reference point, start here: https://github.com/charmbracelet/taskcli/blob/main/cmds.go
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "nestri",
|
||||
Short: "A CLI tool to manage your cloud gaming service",
|
||||
@@ -29,7 +31,6 @@ var rootCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
// this is for the "nestri neofetch" subcommand, has no arguments
|
||||
var neoFetchCmd = &cobra.Command{
|
||||
Use: "neofetch",
|
||||
Short: "Show important system information",
|
||||
@@ -37,16 +38,16 @@ var neoFetchCmd = &cobra.Command{
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
lipgloss.SetColorProfile(termenv.TrueColor)
|
||||
|
||||
baseStyle := lipgloss.NewStyle().
|
||||
PaddingTop(1).
|
||||
PaddingRight(4).
|
||||
PaddingBottom(1).
|
||||
PaddingLeft(4)
|
||||
// baseStyle := lipgloss.NewStyle().
|
||||
// MarginTop(1).
|
||||
// MarginRight(4).
|
||||
// MarginBottom(1).
|
||||
// MarginLeft(4)
|
||||
|
||||
var (
|
||||
b strings.Builder
|
||||
lines = strings.Split(art, "\n")
|
||||
colors = []string{"#F8481C", "#F74127", "#F53B30", "#F23538", "#F02E40"}
|
||||
colors = []string{"#CC3D00", "#CC3D00"}
|
||||
step = len(lines) / len(colors)
|
||||
)
|
||||
|
||||
@@ -57,9 +58,17 @@ var neoFetchCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
t := table.New().
|
||||
Border(lipgloss.HiddenBorder())
|
||||
Border(lipgloss.HiddenBorder()).BorderStyle(lipgloss.NewStyle().Width(3))
|
||||
//TODO: show this specs
|
||||
// info := &specs.Specs{}
|
||||
// infoChan := make(chan specs.Specs, 1)
|
||||
// var wg sync.WaitGroup
|
||||
// wg.Add(1)
|
||||
// go getSpecs(info, infoChan, &wg)
|
||||
// wg.Wait()
|
||||
// newInfo := <-infoChan
|
||||
|
||||
t.Row(baseStyle.Render(b.String()), baseStyle.Render("System Info goes here"))
|
||||
t.Row(b.String())
|
||||
|
||||
fmt.Print(t)
|
||||
|
||||
@@ -67,17 +76,6 @@ var neoFetchCmd = &cobra.Command{
|
||||
},
|
||||
}
|
||||
|
||||
// this is the "nestri run" subcommand, takes no arguments for now
|
||||
var runCmd = &cobra.Command{
|
||||
Use: "run",
|
||||
Short: "Run a game using nestri",
|
||||
Args: cobra.NoArgs,
|
||||
//For now just show the "help"
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cmd.Help()
|
||||
},
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
@@ -88,12 +86,16 @@ func Execute() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Here you will define your flags and configuration settings.
|
||||
// Cobra supports persistent flags, which, if defined here,
|
||||
// will be global for your application.
|
||||
rootCmd.AddCommand(neoFetchCmd)
|
||||
|
||||
rootCmd.AddCommand(runCmd)
|
||||
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cli.yaml)")
|
||||
|
||||
//If you want to add subcommands to run for example "netri run -fsr" do it like this
|
||||
// runCmd.Flags().BoolP("fsr", "f", false, "Run the Game with FSR enabled or not")
|
||||
// Cobra also supports local flags, which will only run
|
||||
// when this action is called directly.
|
||||
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func colorize(c, s string) string {
|
||||
@@ -120,3 +122,19 @@ func max(a, b int) int {
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func getSpecs(info *specs.Specs, infoChan chan specs.Specs, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
sys := specs.New()
|
||||
// info.Userhost = getUserHostname()
|
||||
// info.OS = getOSName()
|
||||
// info.Kernel = getKernelVersion()
|
||||
// info.Uptime = getUptime()
|
||||
// info.Shell = getShell()
|
||||
// info.CPU = getCPUName()
|
||||
// info.RAM = getMemStats()
|
||||
info.GPU, _ = sys.GetGPUInfo()
|
||||
// info.SystemArch, _ = getSystemArch()
|
||||
// info.DiskUsage, _ = getDiskUsage()
|
||||
infoChan <- *info
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module github.com/netrisdotme/cli
|
||||
module github.com/nestriness/cli
|
||||
|
||||
go 1.22.2
|
||||
|
||||
|
||||
3
main.go
3
main.go
@@ -1,10 +1,9 @@
|
||||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
|
||||
*/
|
||||
package main
|
||||
|
||||
import "github.com/netrisdotme/cli/cmd"
|
||||
import "github.com/nestriness/cli/cmd"
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
|
||||
76
pkg/specs/system.go
Normal file
76
pkg/specs/system.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package specs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SysSpecs struct {
|
||||
osx string
|
||||
}
|
||||
|
||||
func New() *SysSpecs {
|
||||
return &SysSpecs{osx: runtime.GOOS}
|
||||
}
|
||||
|
||||
func (s SysSpecs) GetGPUInfo() (string, error) {
|
||||
var output []byte
|
||||
var err error
|
||||
|
||||
switch s.osx {
|
||||
case "windows":
|
||||
output, err = exec.Command("wmic", "path", "win32_VideoController", "get", "name").Output()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error retrieving GPU information on Windows: %v", err)
|
||||
}
|
||||
case "darwin":
|
||||
output, err = exec.Command("system_profiler", "SPDisplaysDataType").Output()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error retrieving GPU information on macOS: %v", err)
|
||||
}
|
||||
case "linux":
|
||||
output, err = exec.Command("lspci", "-vnn").Output()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error retrieving GPU information on Linux: %v", err)
|
||||
}
|
||||
default:
|
||||
return "", fmt.Errorf("error: GPU information retrieval not implemented for %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
outputStr := strings.TrimSpace(string(output))
|
||||
|
||||
if s.osx == "windows" {
|
||||
lines := strings.Split(outputStr, "\r\n")[1:]
|
||||
gpuName := strings.TrimSpace(strings.Join(lines, " "))
|
||||
return gpuName, nil
|
||||
}
|
||||
|
||||
if s.osx == "darwin" {
|
||||
lines := strings.Split(outputStr, "\n")
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "Chipset Model:") {
|
||||
fields := strings.Split(line, ":")
|
||||
if len(fields) >= 2 {
|
||||
gpuName := strings.TrimSpace(fields[1])
|
||||
return gpuName, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("error parsing GPU information on macOS")
|
||||
}
|
||||
|
||||
lines := strings.Split(outputStr, "\n")
|
||||
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "VGA compatible controller") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) > 2 {
|
||||
gpuName := strings.Join(fields[2:], " ")
|
||||
return gpuName, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("error parsing GPU information on Linux")
|
||||
}
|
||||
14
pkg/specs/types.go
Normal file
14
pkg/specs/types.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package specs
|
||||
|
||||
type Specs struct {
|
||||
Userhost string
|
||||
OS string
|
||||
Kernel string
|
||||
Uptime string
|
||||
Shell string
|
||||
CPU string
|
||||
RAM string
|
||||
GPU string
|
||||
SystemArch string
|
||||
DiskUsage string
|
||||
}
|
||||
Reference in New Issue
Block a user