neowofetch/utils/args.go

52 lines
1,015 B
Go
Raw Permalink Normal View History

2022-09-22 12:48:20 +02:00
package utils
import (
"os"
2022-09-25 10:24:09 +02:00
"os/exec"
2022-09-22 12:48:20 +02:00
"strings"
)
var args []string
var shoulduwuify bool = true
var noascii bool = false
2022-09-22 14:44:27 +02:00
var usepng bool = false
var hascolor bool = true
2022-09-25 10:24:09 +02:00
var Customascii = false
var asciidir string
2022-09-25 12:27:18 +02:00
var asciiforced = false
var forceddistro string
2022-09-22 12:48:20 +02:00
2022-09-25 12:27:18 +02:00
func Gethn() string {
cmd := exec.Command("whoami")
shell, _ := cmd.Output()
return strings.Replace(string(shell), "\n", "", -1)
}
2022-09-22 12:48:20 +02:00
func Initargs() {
args = os.Args[1:]
for _, argument := range args {
2022-09-25 10:24:09 +02:00
if strings.HasPrefix(argument, "--ascii=") {
Customascii = true
2022-09-25 12:27:18 +02:00
asciidir = strings.ReplaceAll(argument[8:], "~", "/home/"+Gethn())
}
if strings.HasPrefix(argument, "--distro=") {
asciiforced = true
forceddistro = argument[9:]
2022-09-25 10:24:09 +02:00
} else if strings.HasPrefix(argument, "--") {
2022-09-22 12:48:20 +02:00
switch argument {
case "--nouwu":
shoulduwuify = false
case "--noascii":
noascii = true
2022-09-22 14:44:27 +02:00
case "--usepng":
usepng = true
case "--nocolor":
hascolor = false
2022-09-22 12:48:20 +02:00
}
}
}
}
func Woulduwuify() bool {
return shoulduwuify
}