Documentation
¶
Index ¶
- Constants
- Variables
- func CreateExampleHabitsFile(configDir string)
- func CreateNewLogFile(configDir string)
- func FindConfigFiles() string
- func IsNotDigit(r rune) bool
- func WriteHabitLog(configDir string, d civil.Date, habit string, result string, comment string, ...) error
- type DailyHabit
- type Entries
- type FileRepository
- func (r *FileRepository) GetConfigDir() string
- func (r *FileRepository) InitializeConfig() error
- func (r *FileRepository) LoadEntries() (*Log, error)
- func (r *FileRepository) LoadHabits() ([]*Habit, int, error)
- func (r *FileRepository) WriteEntry(d civil.Date, habit string, result string, comment string, amount string, ...) error
- type Habit
- type Header
- type Log
- type Outcome
- type Repository
Constants ¶
const ( HeaderDate = "Date" HeaderAmount = "Amount" HeaderComment = "Comment" HeaderHabit = "Habit" HeaderStatus = "Status" )
const DEFAULT_HABITS = `` /* 472-byte string literal not displayed */
Variables ¶
var DefaultHeader = Header{ HeaderDate: 0, HeaderHabit: 1, HeaderStatus: 2, HeaderComment: 3, HeaderAmount: 4, }
Functions ¶
func CreateExampleHabitsFile ¶
func CreateExampleHabitsFile(configDir string)
CreateExampleHabitsFile writes a fresh Habits file for people to follow
func CreateNewLogFile ¶
func CreateNewLogFile(configDir string)
CreateNewLogFile writes an empty log file for people to start tracking into
func FindConfigFiles ¶
func FindConfigFiles() string
FindConfigFiles checks os relevant habits and log file exist, returns path If they do not exist, calls CreateExampleHabitsFile and CreateNewLogFile
func IsNotDigit ¶
Types ¶
type DailyHabit ¶
DailyHabit combines Day and Habit with an Outcome to yield Entries
type Entries ¶
type Entries map[DailyHabit]Outcome
Entries maps DailyHabit{ISO date + habit}: Outcome and log format
type FileRepository ¶
type FileRepository struct {
// contains filtered or unexported fields
}
FileRepository implements Repository using file-based storage
func NewFileRepository ¶
func NewFileRepository() *FileRepository
NewFileRepository creates a new file-based repository
func (*FileRepository) GetConfigDir ¶
func (r *FileRepository) GetConfigDir() string
GetConfigDir returns the configuration directory
func (*FileRepository) InitializeConfig ¶
func (r *FileRepository) InitializeConfig() error
InitializeConfig initializes the configuration if needed
func (*FileRepository) LoadEntries ¶
func (r *FileRepository) LoadEntries() (*Log, error)
LoadEntries loads log entries from the log file
func (*FileRepository) LoadHabits ¶
func (r *FileRepository) LoadHabits() ([]*Habit, int, error)
LoadHabits loads habits from the config file
type Habit ¶
type Habit struct {
Heading string
Name string
Frequency string
Target int
Interval int
FirstRecord civil.Date
}
Habit represents a habit with its configuration and tracking information
func LoadHabitsConfig ¶
LoadHabitsConfig loads habits in config file ordered slice
func (*Habit) ParseHabitFrequency ¶
func (habit *Habit) ParseHabitFrequency()
ParseHabitFrequency parses the frequency string and sets Target and Interval
type Header ¶
func ParseHeader ¶
type Outcome ¶
Outcome is the explicit recorded result of a habit on a day (y, n, or s) and an optional amount and comment
type Repository ¶
type Repository interface {
// Habit operations
LoadHabits() ([]*Habit, int, error)
// Log operations
LoadEntries() (*Log, error)
WriteEntry(d civil.Date, habit string, result string, comment string, amount string, header Header) error
// Configuration
GetConfigDir() string
InitializeConfig() error
}
Repository defines the interface for data access operations