config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package config handles loading and validating sked configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindOrCreateDefault

func FindOrCreateDefault() (string, error)

FindOrCreateDefault finds the default config file, creating it if it doesn't exist. It returns the path to the config file.

Types

type Config

type Config struct {
	CycleDays    int        `toml:"cycle_days"`
	AnchorDate   string     `toml:"anchor_date"`
	CSVPath      string     `toml:"csv_path"`
	TmpCSVPath   string     `toml:"tmp_csv_path"`
	DateFormat   string     `toml:"date_format"`
	Days         []Day      `toml:"day"`
	Overrides    []Override `toml:"override"`
	SkipWeekends bool       `toml:"skip_weekends"`
	Saturday     []Task     `toml:"saturday"`
	Sunday       []Task     `toml:"sunday"`
}

Config represents the top-level configuration structure.

func Load

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

Load reads the configuration from the specified path. It detects the format based on the file extension (.toml or .csv).

func LoadCSV

func LoadCSV(path string, dateFormat string) (*Config, error)

LoadCSV reads a CSV configuration file. CSV format assumes a standard 7-day cycle. Header: Start,End,Mon,Tue,Wed,Thu,Fri,Sat,Sun (flexible day column order)

func LoadTOML

func LoadTOML(path string) (*Config, error)

LoadTOML reads a TOML configuration file.

func LoadTmpCSV

func LoadTmpCSV(path string) (*Config, error)

LoadTmpCSV reads a temporary CSV configuration file. It expects "Start", "End", and "Task" columns. Tasks are assigned to the current day (as of when this function is called).

func (*Config) ProcessOverrides

func (c *Config) ProcessOverrides() error

ProcessOverrides parses raw override data into usable structs.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid.

type Day

type Day struct {
	ID    int    `toml:"id"`
	Tasks []Task `toml:"tasks"`
}

Day represents a single day's schedule in the cycle.

type DayID added in v0.1.4

type DayID int

DayID is Used for flexible config for either number-based or word-based day of week

func (*DayID) UnmarshalTOML added in v0.1.4

func (d *DayID) UnmarshalTOML(data any) error

func (*DayID) UnmarshalText added in v0.1.4

func (d *DayID) UnmarshalText(text []byte) error

type Override

type Override struct {
	DateStr    string `toml:"date"`
	EndDateStr string `toml:"end_date"`
	IsOff      bool   `toml:"is_off"`
	UseDayID   DayID  `toml:"use_day_id"`

	// Internal fields populated during validation
	Date    time.Time `toml:"-"`
	EndDate time.Time `toml:"-"`
}

Override represents a temporary schedule change for a specific date.

type Task

type Task struct {
	Name  string `toml:"name"`
	Start string `toml:"start"`
	End   string `toml:"end"`
}

Task represents a specific activity.

Jump to

Keyboard shortcuts

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