neowofetch/utils/args.go

63 lines
1.3 KiB
Go
Raw 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
var Asciiforced = false
var Forceddistro string
var Defaultconf bool = false
var Defaultcolor bool = false
2022-10-13 09:32:18 +02:00
var colorold bool = false
2022-12-25 07:07:48 +01:00
var Ishelp bool = false
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
case "--noconf":
Defaultconf = true
case "--nocolorconf":
Defaultcolor = true
2022-10-13 09:32:18 +02:00
case "--16color":
colorold = true
2022-12-25 07:07:48 +01:00
case "--help":
Ishelp = true
2022-10-13 09:32:18 +02:00
default:
2022-12-25 07:07:48 +01:00
print("unknown argument: ", argument, ". please run --help for help\n")
2022-10-13 09:32:18 +02:00
os.Exit(0)
2022-09-22 12:48:20 +02:00
}
}
}
}