Documentation
¶
Overview ¶
Package config provides configuration file parsing and validation.
Index ¶
- func DeleteGame(configDir string, gameID string) error
- func DeleteProfile(configDir, gameID, profileName string) error
- func ExpandPath(path string) string
- func ExportProfile(profile *domain.Profile) ([]byte, error)
- func ImportProfile(data []byte) (*domain.Profile, error)
- func ListProfiles(configDir, gameID string) ([]string, error)
- func LoadGames(configDir string) (map[string]*domain.Game, error)
- func LoadProfile(configDir, gameID, profileName string) (*domain.Profile, error)
- func ParseConfigPath(path string) (string, error)
- func SaveGame(configDir string, game *domain.Game) error
- func SaveProfile(configDir string, profile *domain.Profile) error
- type Config
- type GameConfig
- type GamesFile
- type ModReferenceConfig
- type ProfileConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteGame ¶
DeleteGame removes a game from games.yaml
func DeleteProfile ¶
DeleteProfile removes a profile from disk
func ExpandPath ¶
ExpandPath expands ~ to the user's home directory
func ExportProfile ¶
ExportProfile exports a profile to a portable format
func ImportProfile ¶
ImportProfile imports a profile from portable format
func ListProfiles ¶
ListProfiles returns all profile names for a game
func LoadProfile ¶
LoadProfile reads a profile from disk
func ParseConfigPath ¶
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
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
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