base code for color added
This commit is contained in:
parent
3f42e2d147
commit
b6f1827ea5
3 changed files with 62 additions and 33 deletions
6
go.mod
6
go.mod
|
@ -2,3 +2,9 @@ module github.com/exhq/neowofetch
|
||||||
|
|
||||||
go 1.19
|
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
24
main.go
|
@ -45,8 +45,9 @@ func handleConfig() {
|
||||||
body, _ := ioutil.ReadFile(getConfigFile())
|
body, _ := ioutil.ReadFile(getConfigFile())
|
||||||
fbody := strings.Split(string(body), "\n")
|
fbody := strings.Split(string(body), "\n")
|
||||||
util.InitUwuPrinter()
|
util.InitUwuPrinter()
|
||||||
for _, s := range fbody {
|
for i, s := range fbody {
|
||||||
w := strings.SplitN(s, " ", 2)
|
w := strings.SplitN(s, " ", 2)
|
||||||
|
|
||||||
if len(w) < 2 {
|
if len(w) < 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -58,14 +59,14 @@ func handleConfig() {
|
||||||
argument = argument[5:]
|
argument = argument[5:]
|
||||||
}
|
}
|
||||||
if verb == "print" {
|
if verb == "print" {
|
||||||
util.UwuPrint(argument, nouwu)
|
util.UwuPrint(argument, nouwu, fbody[i])
|
||||||
} else if verb == "println" {
|
} else if verb == "println" {
|
||||||
util.UwuPrint(argument, nouwu)
|
util.UwuPrint(argument, nouwu, fbody[i])
|
||||||
util.UwuNewline()
|
util.UwuNewline()
|
||||||
} else if verb == "info" {
|
} else if verb == "info" {
|
||||||
PrintInfo(argument, nouwu)
|
PrintInfo(argument, nouwu, strings.Join(fbody, ""))
|
||||||
} else if verb == "infoln" {
|
} else if verb == "infoln" {
|
||||||
PrintInfo(argument, nouwu)
|
PrintInfo(argument, nouwu, strings.Join(fbody, ""))
|
||||||
util.UwuNewline()
|
util.UwuNewline()
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Unknown verb %s\n", verb)
|
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" {
|
if infoType == "username" {
|
||||||
util.UwuPrint(getUsername(), noUwuOverride)
|
util.UwuPrint(getUsername(), noUwuOverride, whole)
|
||||||
} else if infoType == "hostname" {
|
} else if infoType == "hostname" {
|
||||||
util.UwuPrint(getHostname(), noUwuOverride)
|
util.UwuPrint(getHostname(), noUwuOverride, whole)
|
||||||
} else if infoType == "uptime" {
|
} else if infoType == "uptime" {
|
||||||
among, _ := strconv.Atoi(getUptime())
|
among, _ := strconv.Atoi(getUptime())
|
||||||
util.UwuPrint(formatTime(among), true)
|
util.UwuPrint(formatTime(among), true, whole)
|
||||||
} else if infoType == "distro" {
|
} else if infoType == "distro" {
|
||||||
util.UwuPrint(getDistro(), noUwuOverride)
|
util.UwuPrint(getDistro(), noUwuOverride, whole)
|
||||||
|
} else if infoType == "terminal" {
|
||||||
|
util.UwuPrint(getTerminal(), noUwuOverride, whole)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleArgs() {
|
func handleArgs() {
|
||||||
|
|
|
@ -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
|
//will add color eventually, my brain hurts
|
||||||
|
var hadAnyContent bool
|
||||||
|
var wholeword string
|
||||||
|
var checkspaces int
|
||||||
|
isuwu := true
|
||||||
initLine()
|
initLine()
|
||||||
if noUwuOverride || !shouldUwuify {
|
if noUwuOverride || !shouldUwuify {
|
||||||
print(message)
|
isuwu = false
|
||||||
return
|
wholeword = message
|
||||||
}
|
}
|
||||||
words := strings.Split(message, " ")
|
notuwuified := ""
|
||||||
hadAnyContent := false
|
if isuwu {
|
||||||
for _, word := range words {
|
words := strings.Split(message, " ")
|
||||||
if word == "" {
|
hadAnyContent = false
|
||||||
print(" ")
|
for _, word := range words {
|
||||||
continue
|
notuwuified += word
|
||||||
}
|
if word == "" {
|
||||||
word = strings.ReplaceAll(word, "r", "w")
|
checkspaces += 1
|
||||||
word = strings.ReplaceAll(word, "i", "iy")
|
continue
|
||||||
word = strings.ReplaceAll(word, "iyy", "iy")
|
}
|
||||||
word = strings.ReplaceAll(word, "l", "w")
|
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, "!") {
|
if strings.HasSuffix(word, "!") {
|
||||||
word = word[:len(word)-1] + "1!11!1"
|
word = word[:len(word)-1] + "1!11!1"
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(word, "u") &&
|
if strings.Contains(word, "u") &&
|
||||||
!strings.Contains(word, "uwu") &&
|
!strings.Contains(word, "uwu") &&
|
||||||
!strings.Contains(word, "owo") {
|
!strings.Contains(word, "owo") {
|
||||||
word = strings.ReplaceAll(word, "u", "uwu")
|
word = strings.ReplaceAll(word, "u", "uwu")
|
||||||
|
}
|
||||||
|
hadAnyContent = true
|
||||||
|
wholeword += word
|
||||||
}
|
}
|
||||||
hadAnyContent = true
|
|
||||||
print(word)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if hadAnyContent && rand.Intn(5) == 0 {
|
if hadAnyContent && rand.Intn(5) == 0 {
|
||||||
print(uwuEmotes[rand.Intn(len(uwuEmotes))])
|
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() {
|
func UwuNewline() {
|
||||||
|
|
Loading…
Reference in a new issue