From 66f4e514cae061c722dd51af98a2db4eb3216da5 Mon Sep 17 00:00:00 2001 From: echo <91651232+exhq@users.noreply.github.com> Date: Thu, 22 Sep 2022 14:18:20 +0330 Subject: [PATCH] bruh --- asciiart/README | 0 main.go | 50 ++++++++-------------- utils/args.go | 36 ++++++++++++++++ asciiart/asciiart.go => utils/asciiarts.go | 2 +- 4 files changed, 55 insertions(+), 33 deletions(-) delete mode 100644 asciiart/README create mode 100644 utils/args.go rename asciiart/asciiart.go => utils/asciiarts.go (96%) diff --git a/asciiart/README b/asciiart/README deleted file mode 100644 index e69de29..0000000 diff --git a/main.go b/main.go index d7e7b59..5eaa6b6 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" "io/ioutil" - "neowofetch/asciiart" + "neowofetch/utils" "os" "os/exec" "path/filepath" @@ -14,7 +14,7 @@ import ( ) var isuwuified bool = true -var linearch []string +var asciiart []string var aa int func getHome() string { @@ -30,9 +30,9 @@ func getConfigFile() string { } func initascii() { - linearch = asciiart.Getascii(getDistro()) + asciiart = utils.Asciioverwrite(utils.Getascii(getDistro())) aa = 0 - print(linearch[aa]) + print(asciiart[aa]) aa = aa + 1 } @@ -72,15 +72,15 @@ func handlePrint(action, colour string, rest string) { } else if action == "println" { Cprint(colour, rest, true) print("\n") - if aa < len(linearch) { - print(linearch[aa]) + if aa < len(asciiart) { + print(asciiart[aa]) } - if aa == len(linearch) || aa == len(linearch)-1 { - print(strings.Repeat(" ", len(linearch[1]))) + if aa == len(asciiart) || aa == len(asciiart)-1 { + print(strings.Repeat(" ", len(asciiart[1]))) } - if aa > len(linearch) { - print(strings.Repeat(" ", len(linearch[1]))) + if aa > len(asciiart) { + print(strings.Repeat(" ", len(asciiart[1]))) } incrementaa() } else if action == "info" || action == "infoln" { @@ -111,19 +111,18 @@ func handlePrint(action, colour string, rest string) { if action == "infoln" { print("\n") - if aa < len(linearch) { - print(linearch[aa]) + if aa < len(asciiart) { + print(asciiart[aa]) } else { - print(strings.Repeat(" ", len(linearch[1]))) + print(strings.Repeat(" ", len(asciiart[1]))) } incrementaa() } } 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) } yellow := color.New(color.FgYellow).SprintFunc() @@ -181,19 +180,6 @@ func uwuify(message string) string { 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 { cmd := exec.Command("uname", "-n") shell, _ := cmd.Output() @@ -328,9 +314,9 @@ func getMemory(used bool) string { } func handleremainingascii() { - if aa < len(linearch) { - for i := 0; i < len(linearch)-aa; i++ { - print("\n", linearch[aa]) + if aa < len(asciiart) { + for i := 0; i < len(asciiart)-aa; i++ { + print("\n", asciiart[aa]) incrementaa() } @@ -349,8 +335,8 @@ func getColorPalette() { } func main() { + utils.Initargs() initascii() - handleArgs() handleConfig() handleremainingascii() print("\n") diff --git a/utils/args.go b/utils/args.go new file mode 100644 index 0000000..978d0d1 --- /dev/null +++ b/utils/args.go @@ -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 + } +} diff --git a/asciiart/asciiart.go b/utils/asciiarts.go similarity index 96% rename from asciiart/asciiart.go rename to utils/asciiarts.go index 4bd6315..7343143 100644 --- a/asciiart/asciiart.go +++ b/utils/asciiarts.go @@ -1,4 +1,4 @@ -package asciiart +package utils import ( "strings"