Documentation ¶
Overview ¶
Package config provides functions for caching state
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { Days int `comment:"Upcoming days to show"` Calendars []Calendar `comment:"List of calendars"` }
Configuration allows for saving program Configuration and settings
func LoadConfig ¶
func LoadConfig() *Configuration
LoadConfig attempts to load the existing configuration file. If an error occurs (i.e. the configuration file does not exist) a default configuration object is returned.
func (*Configuration) AddCalendar ¶
func (cfg *Configuration) AddCalendar(args ...string)
AddCalendar adds a new named calendar to the configuration.
It expects calendar name and URL in alternating order.
func (*Configuration) DeleteCalendar ¶
func (cfg *Configuration) DeleteCalendar(args ...string)
DeleteCalendar removes a calendar from the configuration.
It expects calendar names to be passed via args
func (*Configuration) ListCalendars ¶
func (cfg *Configuration) ListCalendars(out io.Writer)
ListCalendars prints the list of calendars in the configuration to the interface implemented by out.
func (*Configuration) Save ¶
func (s *Configuration) Save() error
Save writes the configuration to disk
func (*Configuration) SaveExit ¶
func (s *Configuration) SaveExit()
SaveExit is an equivalent to Save(), followed by os.Exit(0) if no error occurs.
If an error occurs, log.Fatal is called.
func (*Configuration) SelectCalendars ¶
func (cfg *Configuration) SelectCalendars(args ...string)
SelectCalendars processes arguments into a map of calendars:
- If an argument matches the name of a configured calendar, it will be included
- If valid URL is passed, it will be included
All other calendars will be filtered from the configuration.