krampus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ElfEnvPrefix          string = "ELF"
	DefaultConfigFileBase string = "elf"
	DefaultConfigExt      string = "toml"
)

Variables

This section is empty.

Functions

func WithFile

func WithFile(f string) func(*Config)

WithFile sets the configuration file and type.

If the file is empty, the default file name and type are used.

func WithFs

func WithFs(fs afero.Fs) func(*Config)

WithFs sets the file system.

If the file system is nil, a new OS file system is used.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(options ...func(*Config)) (Config, error)

func (Config) GetBaseDir

func (c Config) GetBaseDir() string

func (Config) GetCacheDir

func (c Config) GetCacheDir() string

func (Config) GetConfigDir

func (c Config) GetConfigDir() string

func (Config) GetConfigFileUsed

func (c Config) GetConfigFileUsed() string

GetConfigFileUsed returns the configuration file used.

If no configuration file is loaded, an empty string is returned. Failure to read a configuration file does not cause an error and will still result in an empty string.

func (Config) GetFs

func (c Config) GetFs() afero.Fs

func (Config) GetInputFilename

func (c Config) GetInputFilename() string

func (Config) GetLanguage

func (c Config) GetLanguage() string

GetLanguage returns the configured default implementation language.

If no language is configured, an empty string is returned.

func (Config) GetLogger

func (c Config) GetLogger() *slog.Logger

func (Config) GetToken

func (c Config) GetToken() string

GetToken returns the authentication token for downloading exercises.

type ConfigKey

type ConfigKey string

ConfigKey is a type for configuration keys.

const (
	LanguageKey  ConfigKey = "language"   // Configuration key for the the default implementation language.
	ConfigDirKey ConfigKey = "config-dir" // Configuration key for application configuration files.
	CacheDirKey  ConfigKey = "cache-dir"  // Configuration key for cached application data.
	InputFileKey ConfigKey = "input-file" // InputFileKey is the configuration key for the default input file name.

	AdventTokenKey ConfigKey = "advent.token" // Configuration key for the Advent of Code auth token.
	AdventUserKey  ConfigKey = "advent.user"  // Configuration key for the Advent of Code user name.
	AdventDirKey   ConfigKey = "advent.dir"   // Configuration key for the Advent of Code exercise directory.

	EulerUserKey ConfigKey = "euler.user" // Configuration key for the Project Euler user name.
	EulerDirKey  ConfigKey = "euler.dir"  // Configuration key for Project Euler problem directory.
)

func (ConfigKey) String

func (k ConfigKey) String() string

type ConfigurationReader

type ConfigurationReader interface {
	// GetConfigFileUsed returns the configuration file used.
	GetConfigFileUsed() string
}

ConfigurationReader is an interface that defines methods for reading configuration.

type DownloadConfiguration

type DownloadConfiguration interface {
	ExerciseConfiguration

	// GetCacheDir returns the directory where downloaded exercises are cached.
	GetCacheDir() string

	// GetConfigDir returns the configuration directory.
	GetConfigDir() string

	// GetInputFilename returns the input filename.
	GetInputFilename() string

	// GetToken returns the authentication token for downloading exercises.
	GetToken() string
}

DownloadConfiguration is an interface that extends the ExerciseConfiguration interface. It represents the configuration for downloading exercises.

type ExerciseConfiguration

type ExerciseConfiguration interface {
	// GetBaseDir returns the base directory.
	GetBaseDir() string

	// GetFs returns the file system.
	GetFs() afero.Fs

	// GetLanguage returns the language.
	GetLanguage() string

	// GetLogger returns the logger.
	GetLogger() *slog.Logger
}

ExerciseConfiguration represents the interface for exercise configuration.

Jump to

Keyboard shortcuts

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