cfg

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2022-2024 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.2.1"

Variables

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

valid lisp hooks

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
	Separator      string
	OutputMode     int
	InvertMatch    bool
	Pattern        string
	PatternR       *regexp.Regexp
	UseFuzzySearch bool
	UseHighlight   bool

	SortMode       string
	SortDescending bool
	SortByColumn   int

	/*
	 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

	// special  case: we use the  config struct to transport  the lisp
	// env trough the program
	Lisp *zygo.Zlisp

	// a path containing lisp scripts to be loaded on startup
	LispLoadPath string

	// config file, optional
	Configfile string

	Settings Settings

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

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(pattern string) error

func (*Config) PrepareSortFlags

func (conf *Config) PrepareSortFlags(flag Sortmode)

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 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

Jump to

Keyboard shortcuts

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