config

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config manages options and settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUserConfig

func CreateUserConfig(userPaths []string) (*koanf.Koanf, error)

CreateUserConfig builds configuration instance from default paths (/etc/logalize/..., ~/.config/logalize/... and ./.logalize.yaml) and other paths from userPaths variable (most likely these come from --config flag(s)).

Types

type Options

type Options struct {
	ConfigPaths []string // path(s) to configuration file(s)

	Theme string // the name of the theme to be used

	Debug bool // add debug info to the output

	NoBuiltinFormats  bool // disable built-in formats
	NoBuiltinPatterns bool // disable built-in patterns
	NoBuiltinWords    bool // disable built-in words
	NoBuiltins        bool // disable built-in formats, patterns and words

	HighlightOnlyFormats  bool // highlight only formats
	HighlightOnlyPatterns bool // highlight only patterns
	HighlightOnlyWords    bool // highlight only words

	DryRun bool // don't alter the input

	NoANSIEscapeSequencesStripping bool // disable removing of ANSI escape sequences from the input

	PrintConfig   bool // print fully merged configuration file and exit the program
	PrintBuiltins bool // print built-in configuration and exit the program
	ListThemes    bool // print all available themes and exit the program
}

Options stores the values of command-line and config options.

func NewOptions

func NewOptions() *Options

NewOptions create new instance of Options with default values.

func (*Options) ReadFromConfig

func (opts *Options) ReadFromConfig(cfg *koanf.Koanf)

ReadFromConfig reads new options from configuration object and override corresponding fields in the *Option instance.

func (*Options) ReadFromFlags

func (opts *Options) ReadFromFlags(flags *pflag.FlagSet)

ReadFromFlags reads new options from command line flags and override corresponding fields in the *Option instance.

type Settings

type Settings struct {
	Config       *koanf.Koanf
	Opts         Options
	Builtins     fs.FS
	ColorProfile termenv.Profile
}

Settings is the representation of the whole application configuration.

func NewSettings

func NewSettings(builtins fs.FS, userConfig *koanf.Koanf, flags *pflag.FlagSet) (Settings, error)

NewSettings creates new Settings instance from built-ins (formats, patterns, words, etc.), user configuration (files in /etc/logalize/..., ~/.config/logalize and ./.logalize.yaml) and command line flags.

func (Settings) ProcessSpecialFlags

func (s Settings) ProcessSpecialFlags() (data string, exit bool)

ProcessSpecialFlags checks flags like --print-config and --list-themes that should produce some text output and then exit the program.

Jump to

Keyboard shortcuts

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