core

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset = "\033[0m"
	Bold  = "\033[1m"
	Dim   = "\033[2m"
	Gray  = "\033[90m"

	// High-contrast, 5-tier blue color scale for the dashboard
	// Using 256-color ANSI codes for better terminal compatibility.
	Color0 = "\033[38;5;250m" // Light Gray (for empty days)
	Blue1  = "\033[38;5;117m" // Lightest Blue
	Blue2  = "\033[38;5;75m"  // Light Blue
	Blue3  = "\033[38;5;33m"  // Medium Blue
	Blue4  = "\033[38;5;21m"  // Darkest Blue
)

ANSI color codes for calm, minimal output

Variables

This section is empty.

Functions

func CleanupStaleSession added in v1.1.6

func CleanupStaleSession(session Session, logAsAbandoned bool) error

CleanupStaleSession removes a stale session file and optionally logs it as abandoned

func DeleteLogEntry added in v1.1.5

func DeleteLogEntry(entryToDelete LogEntry) error

DeleteLogEntry removes a specific log entry from the log files.

func FormatDuration

func FormatDuration(d time.Duration) string

func GetConfigPath added in v1.1.3

func GetConfigPath() (string, error)

GetConfigPath determines the expected path for the configuration file.

func GetLogDir

func GetLogDir() (string, error)

GetLogDir returns the directory containing all log files

func GetLogPath

func GetLogPath(date time.Time) (string, error)

GetLogPath returns the path to the session log file for a specific month

func GetSessionPath

func GetSessionPath() (string, error)

Session file management

func HandleDashboard

func HandleDashboard()

func HandleExport

func HandleExport()

func HandleLog

func HandleLog(showStats, filterToday, filterWeek, filterMonth, showAll bool, monthStr string)

HandleLog handles the log command with improved performance

func IsSessionStale added in v1.1.6

func IsSessionStale(session Session, threshold time.Duration) bool

IsSessionStale checks if a session has been running for an unreasonable amount of time

func LogSession

func LogSession(entry LogEntry) error

LogSession appends a completed session to the appropriate monthly log file

func RunHook

func RunHook(event string, args ...string)

RunHook executes a custom script for a given event

func SaveSession

func SaveSession(session Session) error

func SessionExists

func SessionExists() bool

func ShowVersion

func ShowVersion(version, commit, date string)

Types

type ActivityStat

type ActivityStat struct {
	Tag      string
	Duration time.Duration
	Count    int
}

ActivityStat represents statistics for a specific activity

type Config added in v1.1.2

type Config struct {
	StaleSessionThreshold string `yaml:"stale_session_threshold"`
	// contains filtered or unexported fields
}

Config holds all application configuration.

func LoadConfig added in v1.1.2

func LoadConfig() (Config, error)

LoadConfig loads the configuration from the YAML file, applying defaults.

func (*Config) ParsedStaleSessionThreshold added in v1.1.6

func (c *Config) ParsedStaleSessionThreshold() time.Duration

ParsedStaleSessionThreshold returns the parsed stale session threshold duration.

type LogEntry

type LogEntry struct {
	Tag         string        `json:"tag"`
	StartTime   time.Time     `json:"start_time"`
	EndTime     time.Time     `json:"end_time"`
	Duration    time.Duration `json:"duration"`
	TotalPaused time.Duration `json:"total_paused,omitempty"`
}

LogEntry represents a completed session for logging

func GetRecentSessions added in v1.1.5

func GetRecentSessions(limit int) ([]LogEntry, error)

GetRecentSessions retrieves the most recent log entries.

type LogReader

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

LogReader provides efficient reading of log entries from partitioned files

func NewLogReader

func NewLogReader() (*LogReader, error)

NewLogReader creates a new log reader

func (*LogReader) ReadAllEntries

func (lr *LogReader) ReadAllEntries() ([]LogEntry, error)

ReadAllEntries reads all entries (use with caution for large datasets)

func (*LogReader) ReadMonthEntries

func (lr *LogReader) ReadMonthEntries(month time.Time, limit int) ([]LogEntry, error)

ReadMonthEntries reads entries from a specific month

func (*LogReader) ReadRecentEntries

func (lr *LogReader) ReadRecentEntries(limit int, filterToday, filterWeek bool) ([]LogEntry, error)

ReadRecentEntries reads the most recent entries efficiently

type LogStats

type LogStats struct {
	TotalTime     time.Duration
	TotalSessions int
	AverageTime   time.Duration
	TopActivities []ActivityStat
	DateRange     string
}

LogStats contains aggregated statistics

func CalculateStats

func CalculateStats(entries []LogEntry) LogStats

CalculateStats computes statistics from log entries

type Session

type Session struct {
	Tag            string        `json:"tag"`
	StartTime      time.Time     `json:"start_time"`
	TargetDuration time.Duration `json:"target_duration,omitempty"`
	PausedAt       time.Time     `json:"paused_at,omitempty"`
	IsPaused       bool          `json:"is_paused"`
	TotalPaused    time.Duration `json:"total_paused"`
}

Session represents a Flow work session

func LoadSession

func LoadSession() (Session, error)

Jump to

Keyboard shortcuts

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