added support for environment variables

This commit is contained in:
2022-10-22 10:21:39 +02:00
parent 975510c86a
commit e54435c2e4
4 changed files with 37 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ package cfg
import (
"fmt"
"github.com/gookit/color"
"os"
)
const DefaultSeparator string = `(\s\s+|\t)`
@@ -133,3 +134,21 @@ func (conf *Config) PrepareModeFlags(flag Modeflag) {
conf.OutputMode = Ascii
}
}
func (c *Config) CheckEnv() {
// check for environment vars, command line flags have precedence,
// NO_COLOR is being checked by the color module itself.
if !c.NoNumbering {
_, set := os.LookupEnv("T_NO_HEADER_NUMBERING")
if set {
c.NoNumbering = true
}
}
if len(c.Columns) == 0 {
cols := os.Getenv("T_COLUMNS")
if len(cols) > 1 {
c.Columns = cols
}
}
}