base code for color added

This commit is contained in:
echo 2022-09-11 16:25:08 +04:30
parent 3f42e2d147
commit b6f1827ea5
3 changed files with 62 additions and 33 deletions

6
go.mod
View file

@ -2,3 +2,9 @@ module github.com/exhq/neowofetch
go 1.19
require (
github.com/fatih/color v1.13.0
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
)

24
main.go
View file

@ -45,8 +45,9 @@ func handleConfig() {
body, _ := ioutil.ReadFile(getConfigFile())
fbody := strings.Split(string(body), "\n")
util.InitUwuPrinter()
for _, s := range fbody {
for i, s := range fbody {
w := strings.SplitN(s, " ", 2)
if len(w) < 2 {
continue
}
@ -58,14 +59,14 @@ func handleConfig() {
argument = argument[5:]
}
if verb == "print" {
util.UwuPrint(argument, nouwu)
util.UwuPrint(argument, nouwu, fbody[i])
} else if verb == "println" {
util.UwuPrint(argument, nouwu)
util.UwuPrint(argument, nouwu, fbody[i])
util.UwuNewline()
} else if verb == "info" {
PrintInfo(argument, nouwu)
PrintInfo(argument, nouwu, strings.Join(fbody, ""))
} else if verb == "infoln" {
PrintInfo(argument, nouwu)
PrintInfo(argument, nouwu, strings.Join(fbody, ""))
util.UwuNewline()
} else {
fmt.Printf("Unknown verb %s\n", verb)
@ -74,17 +75,20 @@ func handleConfig() {
}
}
func PrintInfo(infoType string, noUwuOverride bool) {
func PrintInfo(infoType string, noUwuOverride bool, whole string) {
if infoType == "username" {
util.UwuPrint(getUsername(), noUwuOverride)
util.UwuPrint(getUsername(), noUwuOverride, whole)
} else if infoType == "hostname" {
util.UwuPrint(getHostname(), noUwuOverride)
util.UwuPrint(getHostname(), noUwuOverride, whole)
} else if infoType == "uptime" {
among, _ := strconv.Atoi(getUptime())
util.UwuPrint(formatTime(among), true)
util.UwuPrint(formatTime(among), true, whole)
} else if infoType == "distro" {
util.UwuPrint(getDistro(), noUwuOverride)
util.UwuPrint(getDistro(), noUwuOverride, whole)
} else if infoType == "terminal" {
util.UwuPrint(getTerminal(), noUwuOverride, whole)
}
}
func handleArgs() {

View file

@ -64,18 +64,25 @@ func initLine() {
}
}
func UwuPrint(message string, noUwuOverride bool) {
func UwuPrint(message string, noUwuOverride bool, whole string) {
//will add color eventually, my brain hurts
var hadAnyContent bool
var wholeword string
var checkspaces int
isuwu := true
initLine()
if noUwuOverride || !shouldUwuify {
print(message)
return
isuwu = false
wholeword = message
}
notuwuified := ""
if isuwu {
words := strings.Split(message, " ")
hadAnyContent := false
hadAnyContent = false
for _, word := range words {
notuwuified += word
if word == "" {
print(" ")
checkspaces += 1
continue
}
word = strings.ReplaceAll(word, "r", "w")
@ -93,12 +100,24 @@ func UwuPrint(message string, noUwuOverride bool) {
word = strings.ReplaceAll(word, "u", "uwu")
}
hadAnyContent = true
print(word)
wholeword += word
}
}
if hadAnyContent && rand.Intn(5) == 0 {
print(uwuEmotes[rand.Intn(len(uwuEmotes))])
}
wholeword = wholeword + strings.Repeat(" ", checkspaces)
if strings.Contains(notuwuified, "blue") {
handlecolor(wholeword)
} else {
print(wholeword)
}
}
func handlecolor(wholeword string) {
print(wholeword + "bruh")
}
func UwuNewline() {