fixed #5, colorization now always works as expected

This commit is contained in:
2022-10-25 14:24:05 +02:00
parent 001021dac8
commit 417faf3ff2
6 changed files with 36 additions and 60 deletions

View File

@@ -19,7 +19,6 @@ package lib
import (
"errors"
"github.com/gookit/color"
"github.com/tlinden/tablizer/cfg"
"io"
"os"
@@ -32,8 +31,6 @@ func ProcessFiles(c cfg.Config, args []string) error {
return err
}
determineColormode(&c)
for _, fd := range fds {
data, err := parseFile(c, fd, pattern)
if err != nil {
@@ -51,18 +48,6 @@ func ProcessFiles(c cfg.Config, args []string) error {
return nil
}
// find supported color mode, modifies config based on constants
func determineColormode(c *cfg.Config) {
if !isTerminal(os.Stdout) {
color.Disable()
} else {
level := color.TermColorLevel()
colors := cfg.Colors()
c.MatchFG = colors[level]["fg"]
c.MatchBG = colors[level]["bg"]
}
}
func determineIO(c *cfg.Config, args []string) ([]io.Reader, string, error) {
var pattern string
var fds []io.Reader