config

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides configuration file parsing and validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteGame

func DeleteGame(configDir string, gameID string) error

DeleteGame removes a game from games.yaml

func DeleteProfile

func DeleteProfile(configDir, gameID, profileName string) error

DeleteProfile removes a profile from disk

func ExpandPath

func ExpandPath(path string) string

ExpandPath expands ~ to the user's home directory

func ExportProfile

func ExportProfile(profile *domain.Profile) ([]byte, error)

ExportProfile exports a profile to a portable format

func ImportProfile

func ImportProfile(data []byte) (*domain.Profile, error)

ImportProfile imports a profile from portable format

func ListProfiles

func ListProfiles(configDir, gameID string) ([]string, error)

ListProfiles returns all profile names for a game

func LoadGames

func LoadGames(configDir string) (map[string]*domain.Game, error)

LoadGames reads all game configurations from the config directory

func LoadProfile

func LoadProfile(configDir, gameID, profileName string) (*domain.Profile, error)

LoadProfile reads a profile from disk

func ParseConfigPath

func ParseConfigPath(path string) (string, error)

ParseConfigPath validates a config file path and returns the cleaned path if valid. It returns an error if:

  • The path is empty
  • The path is not absolute
  • The path contains parent directory traversal (..)
  • The file does not exist
  • The path points to a directory instead of a file
  • The file does not have a .yaml or .yml extension

func SaveGame

func SaveGame(configDir string, game *domain.Game) error

SaveGame adds or updates a game in games.yaml

func SaveProfile

func SaveProfile(configDir string, profile *domain.Profile) error

SaveProfile writes a profile to disk

Types

type Config

type Config struct {
	DefaultLinkMethod domain.LinkMethod `yaml:"-"`
	LinkMethodStr     string            `yaml:"default_link_method"`
	DefaultGame       string            `yaml:"default_game"`
	Keybindings       string            `yaml:"keybindings"`
	CachePath         string            `yaml:"cache_path"`
}

Config holds global application settings

func Load

func Load(configDir string) (*Config, error)

Load reads configuration from the given directory

func (*Config) Save

func (c *Config) Save(configDir string) error

Save writes configuration to the given directory

type GameConfig

type GameConfig struct {
	Name        string            `yaml:"name"`
	InstallPath string            `yaml:"install_path"`
	ModPath     string            `yaml:"mod_path"`
	Sources     map[string]string `yaml:"sources"`
	LinkMethod  string            `yaml:"link_method"`
	CachePath   string            `yaml:"cache_path"`
}

GameConfig is the YAML representation of a game

type GamesFile

type GamesFile struct {
	Games map[string]GameConfig `yaml:"games"`
}

GamesFile is the top-level games.yaml structure

type ModReferenceConfig

type ModReferenceConfig struct {
	SourceID string `yaml:"source_id"`
	ModID    string `yaml:"mod_id"`
	Version  string `yaml:"version,omitempty"`
}

ModReferenceConfig is the YAML representation of a mod reference

type ProfileConfig

type ProfileConfig struct {
	Name       string               `yaml:"name"`
	GameID     string               `yaml:"game_id"`
	Mods       []ModReferenceConfig `yaml:"mods"`
	LinkMethod string               `yaml:"link_method,omitempty"`
	IsDefault  bool                 `yaml:"is_default,omitempty"`
}

ProfileConfig is the YAML representation of a profile

Jump to

Keyboard shortcuts

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