cfg

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright © 2022-2025 Thomas von Dein

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	Extended = iota + 1
	Orgtbl
	Markdown
	Shell
	Yaml
	CSV
	ASCII
)

used for switching printers

View Source
const DefaultSeparator string = `(\s\s+|\t)`
View Source
const MAXPARTS = 2
View Source
const Version string = "v1.3.3"

Variables

View Source
var DefaultConfigfile = os.Getenv("HOME") + "/.config/tablizer/config"
View Source
var VERSION string // maintained by -x

Functions

func ColorStringToBGColor added in v1.1.0

func ColorStringToBGColor(colorname string) color.Color

same, for background colors

func ColorStringToColor added in v1.1.0

func ColorStringToColor(colorname string) color.Color

translate color string to internal color value

func Getversion

func Getversion() string

main program version generated version string, used by -v contains lib.Version on

main branch, and lib.Version-$branch-$lastcommit-$date on

development branch

Types

type Config

type Config struct {
	Debug          bool
	NoNumbering    bool
	NoHeaders      bool
	Columns        string
	UseColumns     []int
	YankColumns    string
	UseYankColumns []int
	Separator      string
	OutputMode     int
	InvertMatch    bool
	Patterns       []*Pattern
	UseFuzzySearch bool
	UseHighlight   bool

	SortMode        string
	SortDescending  bool
	SortByColumn    string // 1,2
	UseSortByColumn []int  // []int{1,2}

	TransposeColumns    string       // 1,2
	UseTransposeColumns []int        // []int{1,2}
	Transposers         []string     // []string{"/ /-/", "/foo/bar/"}
	UseTransposers      []Transposer // {Search: re, Replace: string}

	/*
	 FIXME: make configurable somehow, config file or ENV
	 see https://github.com/gookit/color.
	*/
	ColorStyle        color.Style
	HighlightStyle    color.Style
	NoHighlightStyle  color.Style
	HighlightHdrStyle color.Style

	NoColor bool

	// config file, optional
	Configfile string

	Settings Settings

	// used for field filtering
	Rawfilters []string
	Filters    map[string]Filter //map[string]*regexp.Regexp

	// -r <file>
	InputFile string
}

internal config

func (*Config) ApplyDefaults added in v1.0.12

func (conf *Config) ApplyDefaults()

func (*Config) CheckEnv added in v1.0.12

func (conf *Config) CheckEnv()

func (*Config) Colors added in v1.1.0

func (conf *Config) Colors() map[color.Level]map[string]color.Color

default color schemes

func (*Config) DetermineColormode added in v1.0.12

func (conf *Config) DetermineColormode()

find supported color mode, modifies config based on constants

func (*Config) ParseConfigfile added in v1.1.0

func (conf *Config) ParseConfigfile() error

Parse config file. Ignore if the file doesn't exist but return an error if it exists but fails to read or parse

func (*Config) PrepareFilters added in v1.2.0

func (conf *Config) PrepareFilters() error

func (*Config) PrepareModeFlags

func (conf *Config) PrepareModeFlags(flag Modeflag)

func (*Config) PreparePattern added in v1.0.12

func (conf *Config) PreparePattern(patterns []*Pattern) error

func (*Config) PrepareSortFlags

func (conf *Config) PrepareSortFlags(flag Sortmode)

func (*Config) PrepareTransposers added in v1.3.0

func (conf *Config) PrepareTransposers() error

check if transposers match transposer columns and prepare transposer structs

type Filter added in v1.3.2

type Filter struct {
	Regex  *regexp.Regexp
	Negate bool
}

type Modeflag

type Modeflag struct {
	X bool
	O bool
	M bool
	S bool
	Y bool
	A bool
	C bool
}

maps outputmode short flags to output mode, ie. -O => -o orgtbl

type Pattern added in v1.3.2

type Pattern struct {
	Pattern   string
	PatternRe *regexp.Regexp
	Negate    bool
}

type Settings added in v1.2.0

type Settings struct {
	FG             string `hcl:"FG"`
	BG             string `hcl:"BG"`
	HighlightFG    string `hcl:"HighlightFG"`
	HighlightBG    string `hcl:"HighlightBG"`
	NoHighlightFG  string `hcl:"NoHighlightFG"`
	NoHighlightBG  string `hcl:"NoHighlightBG"`
	HighlightHdrFG string `hcl:"HighlightHdrFG"`
	HighlightHdrBG string `hcl:"HighlightHdrBG"`
}

public config, set via config file or using defaults

type Sortmode

type Sortmode struct {
	Numeric bool
	Time    bool
	Age     bool
}

various sort types

type Transposer added in v1.3.0

type Transposer struct {
	Search  regexp.Regexp
	Replace string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL