mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 07:56:12 +00:00
Remove dependency on bash, switch to new module system and simplify code
This commit is contained in:
+11
-10
@@ -2,21 +2,22 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func setupColorMap(asciiArt string) map[string]string {
|
||||
colorMap := make(map[string]string)
|
||||
func setupColorMap(asciiArtHeader string) map[int]string {
|
||||
colorMap := make(map[int]string)
|
||||
colorMap[0] = "\033[0m"
|
||||
|
||||
// Read colors from ascii art
|
||||
if strings.HasPrefix(asciiArt, "#/") {
|
||||
firstLine := strings.Split(asciiArt, "\n")[0]
|
||||
ansiColors := strings.Split(strings.TrimPrefix(firstLine, "#/"), ";")
|
||||
// Return if header is empty
|
||||
if asciiArtHeader == "" {
|
||||
return colorMap
|
||||
}
|
||||
|
||||
for i, ansiColor := range ansiColors {
|
||||
colorMap["C"+strconv.Itoa(i+1)] = fmt.Sprintf("\033[38;5;%sm", ansiColor)
|
||||
}
|
||||
// Read colors from ascii art header
|
||||
ansiColors := strings.Split(strings.TrimPrefix(asciiArtHeader, "#/"), ";")
|
||||
for i, ansiColor := range ansiColors {
|
||||
colorMap[i+1] = fmt.Sprintf("\033[38;5;%sm", ansiColor)
|
||||
}
|
||||
|
||||
return colorMap
|
||||
|
||||
Reference in New Issue
Block a user