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
|
2022-09-23 11:03:50 +02:00
|
|
|
var hascolor bool = true
|
2022-09-25 10:24:09 +02:00
|
|
|
var Customascii = false
|
|
|
|
var asciidir string
|
2022-11-13 18:47:35 +01:00
|
|
|
var Asciiforced = false
|
|
|
|
var Forceddistro string
|
2022-10-04 12:35:41 +02:00
|
|
|
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=") {
|
2022-11-13 18:47:35 +01:00
|
|
|
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
|
2022-09-23 11:03:50 +02:00
|
|
|
case "--nocolor":
|
|
|
|
hascolor = false
|
2022-10-04 12:35:41 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|