added space support, new default config

This commit is contained in:
echo 2022-11-16 10:11:35 +03:30
parent 77a5854a2e
commit 209c3b271d
2 changed files with 11 additions and 2 deletions

View file

@ -26,7 +26,7 @@ func handleConfig() {
if os.IsNotExist(folder) { if os.IsNotExist(folder) {
os.Mkdir(filepath.Dir(data.GetConfigFile()), os.ModePerm) os.Mkdir(filepath.Dir(data.GetConfigFile()), os.ModePerm)
} }
defaultconfig := "println green neOwOfetchh 🔥\ninfo white username\nprint blue @\ninfoln blue hostname\nprint white uptime: \ninfoln red uptime\nprint white shell: \ninfoln blue shell\nprint white distro: \ninfoln blue distro\nprint white terminal: \ninfoln blue terminal\nprint white memory: \ninfo blue memoryUsed\nprint white /\ninfoln blue memoryAll" defaultconfig := "println green neOwOfetchh 🔥\ninfo white username\nprint blue @\ninfoln blue hostname\nprint white|space=12 uptime:\ninfoln red uptime\nprint white|space=12 shell:\ninfoln blue shell\nprint white|space=12 distro:\ninfoln blue distro\nprint white|space=12 terminal:\ninfoln blue terminal\nprint white|space=12 WM:\ninfoln blue wm\nprint white|space=12 memory:\ninfo blue memoryUsed\nprint white /\ninfoln blue memoryAll"
if os.IsNotExist(file) { if os.IsNotExist(file) {
f, _ := os.Create(data.GetConfigFile()) f, _ := os.Create(data.GetConfigFile())
_, _ = f.WriteString(defaultconfig) _, _ = f.WriteString(defaultconfig)

View file

@ -142,6 +142,7 @@ func uwuify(message string) string {
} }
type Format struct { type Format struct {
spaces int
noUwuOverride bool noUwuOverride bool
colorFormat string colorFormat string
oldcolorFormat int oldcolorFormat int
@ -154,6 +155,10 @@ func parseFormat(format string) (parsedFormat Format) {
if isColor && hascolor { if isColor && hascolor {
parsedFormat.colorFormat += colorFormat parsedFormat.colorFormat += colorFormat
} else { } else {
if strings.HasPrefix(v, "space") {
parsedFormat.spaces, _ = strconv.Atoi(v[6:])
return
}
switch v { switch v {
case "italic": case "italic":
parsedFormat.colorFormat += "\x1b[3m" parsedFormat.colorFormat += "\x1b[3m"
@ -190,8 +195,12 @@ func CutePrint(
if willUwuify { if willUwuify {
message = uwuify(message) message = uwuify(message)
} }
neededspaces := parsedFormat.spaces - len(message)
if neededspaces < 0 {
neededspaces = 0
}
if !colorold { if !colorold {
fmt.Printf("%s%s\x1b[0m", parsedFormat.colorFormat, message) fmt.Printf("%s%s\x1b[0m%s", parsedFormat.colorFormat, message, strings.Repeat(" ", neededspaces))
} else { } else {
if os.IsNotExist(existcolorconf) { if os.IsNotExist(existcolorconf) {
f, _ := os.Create(colorconf) f, _ := os.Create(colorconf)