base code for color added

This commit is contained in:
echo 2022-09-11 16:25:08 +04:30 committed by nea
parent 9935e437d6
commit b4532bee4a
No known key found for this signature in database
GPG key ID: AA563E93EB628D91
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,41 +64,60 @@ 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
}
words := strings.Split(message, " ")
hadAnyContent := false
for _, word := range words {
if word == "" {
print(" ")
continue
}
word = strings.ReplaceAll(word, "r", "w")
word = strings.ReplaceAll(word, "i", "iy")
word = strings.ReplaceAll(word, "iyy", "iy")
word = strings.ReplaceAll(word, "l", "w")
notuwuified := ""
if isuwu {
words := strings.Split(message, " ")
hadAnyContent = false
for _, word := range words {
notuwuified += word
if word == "" {
checkspaces += 1
continue
}
word = strings.ReplaceAll(word, "r", "w")
word = strings.ReplaceAll(word, "i", "iy")
word = strings.ReplaceAll(word, "iyy", "iy")
word = strings.ReplaceAll(word, "l", "w")
if strings.HasSuffix(word, "!") {
word = word[:len(word)-1] + "1!11!1"
}
if strings.HasSuffix(word, "!") {
word = word[:len(word)-1] + "1!11!1"
}
if strings.Contains(word, "u") &&
!strings.Contains(word, "uwu") &&
!strings.Contains(word, "owo") {
word = strings.ReplaceAll(word, "u", "uwu")
if strings.Contains(word, "u") &&
!strings.Contains(word, "uwu") &&
!strings.Contains(word, "owo") {
word = strings.ReplaceAll(word, "u", "uwu")
}
hadAnyContent = true
wholeword += word
}
hadAnyContent = true
print(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() {