remove reuse
This commit is contained in:
parent
c96d264fcd
commit
3a1873a747
34
src/main.go
34
src/main.go
@ -128,6 +128,19 @@ func main() {
|
|||||||
statsLines = append(statsLines, fmt.Sprintf("%s %s%s%s: %s", key, statColor, info.Label, providers.Reset, info.Value))
|
statsLines = append(statsLines, fmt.Sprintf("%s %s%s%s: %s", key, statColor, info.Label, providers.Reset, info.Value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fallbackToAscii := func(path *string) []string {
|
||||||
|
parts := strings.Split(*path, ".")
|
||||||
|
if len(parts) > 1 {
|
||||||
|
parts[len(parts)-1] = "txt"
|
||||||
|
}
|
||||||
|
*path = strings.Join(parts, ".")
|
||||||
|
|
||||||
|
if !strings.HasSuffix(*path, ".txt") {
|
||||||
|
fmt.Println("chafa binary not found, to print images please install chafa")
|
||||||
|
}
|
||||||
|
return providers.SplitLines(providers.PrintAsciiLogo(*path))
|
||||||
|
}
|
||||||
|
|
||||||
var logoLines []string
|
var logoLines []string
|
||||||
if _, err := os.Stat(*logoPath); err == nil {
|
if _, err := os.Stat(*logoPath); err == nil {
|
||||||
if conf.Ascii || (ascii != nil && *ascii) {
|
if conf.Ascii || (ascii != nil && *ascii) {
|
||||||
@ -136,28 +149,11 @@ func main() {
|
|||||||
if err := providers.RenderLogoChafaAnimated(*logoPath, uint(*width), statsLines, position); err == nil {
|
if err := providers.RenderLogoChafaAnimated(*logoPath, uint(*width), statsLines, position); err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
logoLines = fallbackToAscii(logoPath)
|
||||||
parts := strings.Split(*logoPath, ".")
|
|
||||||
if len(parts) > 1 {
|
|
||||||
parts[1] = "txt"
|
|
||||||
}
|
|
||||||
*logoPath = strings.Join(parts, ".")
|
|
||||||
logoLines = providers.SplitLines(providers.PrintAsciiLogo(*logoPath))
|
|
||||||
if strings.Contains(*logoPath, ".txt") != true {
|
|
||||||
fmt.Printf("chafa binary not found, to print images please install chafa\n")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
logoLines, err = providers.RenderLogoChafa(*logoPath, uint(*width))
|
logoLines, err = providers.RenderLogoChafa(*logoPath, uint(*width))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
parts := strings.Split(*logoPath, ".")
|
logoLines = fallbackToAscii(logoPath)
|
||||||
if len(parts) > 1 {
|
|
||||||
parts[1] = "txt"
|
|
||||||
}
|
|
||||||
*logoPath = strings.Join(parts, ".")
|
|
||||||
logoLines = providers.SplitLines(providers.PrintAsciiLogo(*logoPath))
|
|
||||||
if strings.Contains(*logoPath, ".txt") != true {
|
|
||||||
fmt.Printf("chafa binary not found, to print images please install chafa\n")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user