start of argument handling

This commit is contained in:
echo 2022-09-08 20:27:10 +04:30
parent bb5857e17d
commit 620fe45ddc

53
main.go
View file

@ -8,6 +8,21 @@ import (
"strings" "strings"
) )
var isuwuified bool = true
func handleArgs() {
if len(os.Args) == 1 {
return
} else if len(os.Args) > 1 {
args := os.Args
for _, arg := range args {
if arg == "nouwu" {
isuwuified = false
}
}
}
}
func getHostname() string { func getHostname() string {
cmd := exec.Command("uname", "-n") cmd := exec.Command("uname", "-n")
shell, _ := cmd.Output() shell, _ := cmd.Output()
@ -52,13 +67,9 @@ func getKernel() string {
} }
func getUptime() string { func getUptime() string {
cmd := exec.Command("cat", "/proc/uptime") cmd := exec.Command("cat", "/proc/uptime")
uptime, err := cmd.Output() uptime, _ := cmd.Output()
if err != nil {
fmt.Println(err.Error())
return "fuck you"
}
intup, _ := strconv.Atoi(string(uptime[:strings.Count(string(uptime), ".")+3])) intup, _ := strconv.Atoi(string(uptime[:strings.Count(string(uptime), ".")+3]))
return literallyBasicMath(intup) return formatTime(intup)
} }
func getPackages() { func getPackages() {
} }
@ -80,7 +91,7 @@ func getTerminal() string {
return ("exists=" + strconv.FormatBool(exists) + "existprgm=" + strconv.FormatBool(existprgm)) return ("exists=" + strconv.FormatBool(exists) + "existprgm=" + strconv.FormatBool(existprgm))
} }
func getCPU() { func getCPU() {
mem, err := os.Open("/proc/meminfo") mem, err := os.Open("/proc/cpuinfo")
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
os.Exit(0) os.Exit(0)
@ -145,7 +156,7 @@ func getMemory(used bool) string {
} }
} }
func literallyBasicMath(seconds int) string { func formatTime(seconds int) string {
minutes := seconds / 60 minutes := seconds / 60
secondsre := strconv.Itoa(seconds % 60) secondsre := strconv.Itoa(seconds % 60)
hour := strconv.Itoa(minutes / 60) hour := strconv.Itoa(minutes / 60)
@ -157,13 +168,21 @@ func getColorPalette() {
} }
func main() { func main() {
fmt.Print(getUptime(), "\n") /*
//fmt.Print(getTerminal(), "\n")
fmt.Print(getShell(), "\n") fmt.Print(getUptime(), "\n")
fmt.Print(getHostname(), "@", getUsername(), "\n") fmt.Print(getTerminal(), "\n")
fmt.Print(getDistro(), "\n") fmt.Print(getShell(), "\n")
fmt.Print(getGPU(), "\n") fmt.Print(getHostname(), "@", getUsername(), "\n")
fmt.Print(getMemory(true), "\n") fmt.Print(getDistro(), "\n")
fmt.Print(getKernel(), "\n") fmt.Print(getGPU(), "\n")
fmt.Print(13/2, 13%2, "\n") fmt.Print(getMemory(true), "\n")
fmt.Print(getKernel(), "\n")
*/
handleArgs()
if isuwuified {
fmt.Print("shit will be uwuified\n")
} else {
fmt.Print("shit will be NOT uwuified\n")
}
} }