mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 04:30:56 +01:00
added support for environment variables
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -2,8 +2,6 @@
|
||||
|
||||
- rm printYamlData() log.Fatal(), maybe return error on all printers?
|
||||
|
||||
- printShellData() checks Columns unnecessarily (compare to yaml or extended)
|
||||
|
||||
## Features to be implemented
|
||||
|
||||
- add output mode csv
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ func Execute() {
|
||||
}
|
||||
|
||||
// prepare flags
|
||||
conf.CheckEnv()
|
||||
conf.PrepareModeFlags(modeflag)
|
||||
conf.PrepareSortFlags(sortmode)
|
||||
|
||||
|
||||
17
tablizer.pod
17
tablizer.pod
@@ -209,6 +209,23 @@ more output modes available: B<orgtbl> which prints an Emacs org-mode
|
||||
table and B<markdown> which prints a Markdown table and B<yaml>, which
|
||||
prints yaml encoding.
|
||||
|
||||
=head2 ENVIRONMENT VARIABLES
|
||||
|
||||
B<tablizer> supports certain environment variables which use can use
|
||||
to influence program behavior. Commandline flags have always
|
||||
precedence over environment variables.
|
||||
|
||||
=over
|
||||
|
||||
=item <T_NO_HEADER_NUMBERING> - disable numbering of header fields, like B<-n>.
|
||||
|
||||
=item <T_COLUMNS> - comma separated list of columns to output, like B<-c>
|
||||
|
||||
=item <NO_COLORS> - disable colorization of matches, like B<-N>
|
||||
|
||||
=back
|
||||
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
In order to report a bug, unexpected behavior, feature requests
|
||||
|
||||
Reference in New Issue
Block a user