config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config loads and merges convertr configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveWorkers added in v0.1.1

func ResolveWorkers(cfgWorkers int, flagSet bool, flagVal int) int

ResolveWorkers determines the effective worker count. Priority: cfgWorkers (from file+env+profile) is used unless flagSet is true, in which case flagVal wins. A non-positive value resolves to runtime.GOMAXPROCS(0).

Types

type BackendConfig

type BackendConfig struct {
	ExtraArgs []string `toml:"extra_args"`
}

BackendConfig holds per-backend overrides (extra_args, etc.).

type Config

type Config struct {
	Defaults DefaultsConfig           `toml:"defaults"`
	Fonts    fonts.Config             `toml:"fonts"`
	Backend  map[string]BackendConfig `toml:"backend"`
	Profile  map[string]ProfileConfig `toml:"profile"`
}

Config is the top-level configuration structure.

func Default

func Default() Config

Default returns the hardcoded default configuration.

func MergeProfile

func MergeProfile(cfg Config, profileName string) Config

MergeProfile applies profile overrides on top of cfg. Zero/empty fields in the profile leave the corresponding field unchanged.

type DefaultsConfig

type DefaultsConfig struct {
	Quality    int    `toml:"quality"`     // 0 = unset
	Workers    int    `toml:"workers"`     // 0 = GOMAXPROCS
	OnError    string `toml:"on_error"`    // skip|stop|retry
	OnConflict string `toml:"on_conflict"` // overwrite|skip|rename|error
}

DefaultsConfig holds global defaults applied to every conversion.

type FieldSource

type FieldSource struct {
	Quality    Source
	Workers    Source
	OnError    Source
	OnConflict Source
}

FieldSource records the origin of each top-level field.

type Loaded

type Loaded struct {
	Config
	Sources FieldSource
}

Loaded is the resolved configuration together with field provenance.

func Load

func Load(path string) (*Loaded, error)

Load reads the config file at path and applies env overrides. Missing file is not an error — defaults are used.

type ProfileConfig

type ProfileConfig struct {
	Quality    int    `toml:"quality"`
	Workers    int    `toml:"workers"`
	OnError    string `toml:"on_error"`
	OnConflict string `toml:"on_conflict"`
}

ProfileConfig holds named profile overrides that merge over Defaults.

type Source

type Source string

Source identifies where a configuration value came from.

const (
	SourceDefault Source = "default"
	SourceFile    Source = "file"
	SourceEnv     Source = "env"
	SourceFlag    Source = "flag"
)

Jump to

Keyboard shortcuts

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