This commit is contained in:
echo 2022-09-22 14:18:20 +03:30
parent ff5c0f746c
commit 66f4e514ca
4 changed files with 55 additions and 33 deletions

View file

50
main.go
View file

@ -3,7 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"neowofetch/asciiart" "neowofetch/utils"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -14,7 +14,7 @@ import (
) )
var isuwuified bool = true var isuwuified bool = true
var linearch []string var asciiart []string
var aa int var aa int
func getHome() string { func getHome() string {
@ -30,9 +30,9 @@ func getConfigFile() string {
} }
func initascii() { func initascii() {
linearch = asciiart.Getascii(getDistro()) asciiart = utils.Asciioverwrite(utils.Getascii(getDistro()))
aa = 0 aa = 0
print(linearch[aa]) print(asciiart[aa])
aa = aa + 1 aa = aa + 1
} }
@ -72,15 +72,15 @@ func handlePrint(action, colour string, rest string) {
} else if action == "println" { } else if action == "println" {
Cprint(colour, rest, true) Cprint(colour, rest, true)
print("\n") print("\n")
if aa < len(linearch) { if aa < len(asciiart) {
print(linearch[aa]) print(asciiart[aa])
} }
if aa == len(linearch) || aa == len(linearch)-1 { if aa == len(asciiart) || aa == len(asciiart)-1 {
print(strings.Repeat(" ", len(linearch[1]))) print(strings.Repeat(" ", len(asciiart[1])))
} }
if aa > len(linearch) { if aa > len(asciiart) {
print(strings.Repeat(" ", len(linearch[1]))) print(strings.Repeat(" ", len(asciiart[1])))
} }
incrementaa() incrementaa()
} else if action == "info" || action == "infoln" { } else if action == "info" || action == "infoln" {
@ -111,19 +111,18 @@ func handlePrint(action, colour string, rest string) {
if action == "infoln" { if action == "infoln" {
print("\n") print("\n")
if aa < len(linearch) { if aa < len(asciiart) {
print(linearch[aa]) print(asciiart[aa])
} else { } else {
print(strings.Repeat(" ", len(linearch[1]))) print(strings.Repeat(" ", len(asciiart[1])))
} }
incrementaa() incrementaa()
} }
} }
func Cprint(colour string, message string, uwu bool) { func Cprint(colour string, message string, uwu bool) {
nouwu := len(os.Args) == 2 && os.Args[1] == "-nouwu"
if uwu && !nouwu { if uwu && utils.Woulduwuify() {
message = uwuify(message) message = uwuify(message)
} }
yellow := color.New(color.FgYellow).SprintFunc() yellow := color.New(color.FgYellow).SprintFunc()
@ -181,19 +180,6 @@ func uwuify(message string) string {
return answer return answer
} }
func handleArgs() {
if len(os.Args) == 1 {
return
} else if len(os.Args) > 1 {
args := os.Args
for _, arg := range args {
if arg == "nouwu" {
isuwuified = false
}
}
}
}
func getHostname() string { func getHostname() string {
cmd := exec.Command("uname", "-n") cmd := exec.Command("uname", "-n")
shell, _ := cmd.Output() shell, _ := cmd.Output()
@ -328,9 +314,9 @@ func getMemory(used bool) string {
} }
func handleremainingascii() { func handleremainingascii() {
if aa < len(linearch) { if aa < len(asciiart) {
for i := 0; i < len(linearch)-aa; i++ { for i := 0; i < len(asciiart)-aa; i++ {
print("\n", linearch[aa]) print("\n", asciiart[aa])
incrementaa() incrementaa()
} }
@ -349,8 +335,8 @@ func getColorPalette() {
} }
func main() { func main() {
utils.Initargs()
initascii() initascii()
handleArgs()
handleConfig() handleConfig()
handleremainingascii() handleremainingascii()
print("\n") print("\n")

36
utils/args.go Normal file
View file

@ -0,0 +1,36 @@
package utils
import (
"os"
"strings"
)
var args []string
var shoulduwuify bool = true
var noascii bool = false
func Initargs() {
args = os.Args[1:]
for _, argument := range args {
if strings.HasPrefix(argument, "--") {
switch argument {
case "--nouwu":
shoulduwuify = false
case "--noascii":
noascii = true
}
}
}
}
func Woulduwuify() bool {
return shoulduwuify
}
func Asciioverwrite(ascii []string) []string {
if noascii {
literallynothing := []string{"", ""}
return (literallynothing)
} else {
return ascii
}
}

View file

@ -1,4 +1,4 @@
package asciiart package utils
import ( import (
"strings" "strings"