config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultConfig

func CreateDefaultConfig(path string) (err error)

func FindExecutablePath

func FindExecutablePath(executableName string, toolPlatform []string) (path string, ok bool)

func GetDefaultConfigStr

func GetDefaultConfigStr() string

func GetOrCreateUserConfigFile

func GetOrCreateUserConfigFile(warnLog *log.Logger) (path string, created bool, err error)

func QueryPreset

func QueryPreset(presets map[string]Preset, name string) (preset string, isShorthand bool)

func QueryWrapper

func QueryWrapper(wrappers map[string]string, toolPlatform []string, currentPlatform string) (wrapper string)

Types

type CompressionTool

type CompressionTool struct {
	Command          string     `yaml:"command"`
	SupportedFormats []string   `yaml:"supported-formats"`
	Platform         []string   `yaml:"platform"`
	OutputMode       OutputMode `yaml:"output-mode"`
}

func (*CompressionTool) CanBatchCompress

func (ct *CompressionTool) CanBatchCompress() bool

func (*CompressionTool) Overwrites

func (ct *CompressionTool) Overwrites() bool

type Config

type Config struct {
	DefaultPreset string `yaml:"default-preset"`

	MimeExtensions map[string][]string `yaml:"mime-extensions"`

	Wrappers map[string]map[string]string `yaml:"wrappers"`
	Presets  map[string]Preset            `yaml:"presets"`
	Tools    map[string]*ToolConfig       `yaml:"tools"`
	// contains filtered or unexported fields
}

func DecodeConfigFile

func DecodeConfigFile(path string) (cfg *Config, err error)

func (*Config) Cache

func (cfg *Config) Cache()

func (*Config) GetSupportedFileExtensions

func (cfg *Config) GetSupportedFileExtensions() (fileExtMap map[string][]string)

func (*Config) GetSupportedFileFormats

func (cfg *Config) GetSupportedFileFormats() (fileFormatsMime []string)

func (*Config) GetToolConfigFromNames

func (cfg *Config) GetToolConfigFromNames(toolNames []string) (toolCfgMap map[string]*ToolConfig)

func (*Config) HasAvailableTools

func (cfg *Config) HasAvailableTools() bool

func (*Config) IsToolAvailable

func (cfg *Config) IsToolAvailable(toolName string) bool

func (*Config) QueryToolWrapper

func (cfg *Config) QueryToolWrapper(tool *ToolConfig, platform string) string

func (*Config) Validate

func (cfg *Config) Validate() []error

type OutputMode

type OutputMode int
const (
	Unknown OutputMode = iota
	BatchOverwrite
	InputOutput
	Stdout
)

func (OutputMode) MarshalYAML

func (o OutputMode) MarshalYAML() (any, error)

func (*OutputMode) UnmarshalYAML

func (o *OutputMode) UnmarshalYAML(value *yaml.Node) error

type Preset

type Preset struct {
	Description string   `yaml:"description"`
	Shorthands  []string `yaml:"shorthands"`

	DefaultTools map[string][]string `yaml:"default-tools"`
}

type ToolConfig

type ToolConfig struct {
	CompressionTool `yaml:",inline"`
	Description     string              `yaml:"description"`
	Arguments       map[string][]string `yaml:"arguments"`
}

Jump to

Keyboard shortcuts

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