pomo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "undefined"

Functions

func FlushLog

func FlushLog(w io.Writer)

FlushLog writes any buffered log lines to w (typically os.Stderr) and clears the buffer. Safe to call multiple times — no-op when empty.

func FormatStatus

func FormatStatus(status Status) string

func InitDB

func InitDB(db *Store) error

func InitLogger

func InitLogger()

InitLogger routes the standard logger into an in-memory buffer. Call once at program start, before any TUI takes over the terminal.

func LoadConfig

func LoadConfig(configPath string, config *Config) error

func StartUI

func StartUI(runner *TaskRunner)

func SummerizeTasks

func SummerizeTasks(config *Config, tasks []*Task)

Types

type ByID

type ByID []*Task

ByID is a sortable array of tasks

func (ByID) Len

func (b ByID) Len() int

func (ByID) Less

func (b ByID) Less(i, j int) bool

func (ByID) Swap

func (b ByID) Swap(i, j int)

type Client

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

Client makes requests to a listening pomo server to check the status of any currently running task session.

func NewClient

func NewClient(path string) (*Client, error)

func (Client) Close

func (c Client) Close() error

func (Client) Status

func (c Client) Status() (*Status, error)

type ColorMap

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

func (*ColorMap) Get

func (c *ColorMap) Get(name string) *color.Color

func (*ColorMap) MarshalJSON

func (c *ColorMap) MarshalJSON() ([]byte, error)

func (*ColorMap) UnmarshalJSON

func (c *ColorMap) UnmarshalJSON(raw []byte) error

type Config

type Config struct {
	Colors      *ColorMap `json:"colors"`
	DateTimeFmt string    `json:"dateTimeFmt"`
	BasePath    string    `json:"basePath"`
	DBPath      string    `json:"dbPath"`
	SocketPath  string    `json:"socketPath"`
	IconPath    string    `json:"iconPath"`
	OnEvent     []string  `json:"onEvent"`
	// Publish pushes updates to the configured
	// SocketPath rather than listening for requests
	Publish bool `json:"publish"`
	// PublishJson pushes socket updates as a JSON
	// encoded status message instead of string formatted
	PublishJson bool `json:"publishJson"`
	// If Publish is true, provide a socket path to publish to
	PublishSocketPath string `json:"publishSocketPath"`
}

Config represents user preferences

type NoopNotifier

type NoopNotifier struct{}

NoopNotifier does nothing

func (NoopNotifier) Notify

func (n NoopNotifier) Notify(string, string) error

type Notifier

type Notifier interface {
	Notify(string, string) error
}

Notifier sends a system notification

func NewXnotifier

func NewXnotifier(iconPath string) Notifier

type Pomodoro

type Pomodoro struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

Pomodoro is a unit of time to spend working on a single task.

func (Pomodoro) Duration

func (p Pomodoro) Duration() time.Duration

Duration returns the runtime of the pomodoro

type Server

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

Server listens on a Unix domain socket for Pomo status requests

func NewServer

func NewServer(runner *TaskRunner, config *Config) (*Server, error)

func (*Server) Start

func (s *Server) Start()

func (*Server) Stop

func (s *Server) Stop()

type State

type State int
const (
	CREATED State = iota
	RUNNING
	BREAKING
	COMPLETE
	PAUSED
)

func (State) String

func (s State) String() string

type Status

type Status struct {
	TaskID        int           `json:"task_id"`
	TaskMessage   string        `json:"task_message"`
	State         State         `json:"state"`
	Remaining     time.Duration `json:"remaining"`
	Pauseduration time.Duration `json:"pauseduration"`
	Count         int           `json:"count"`
	NPomodoros    int           `json:"n_pomodoros"`
}

Status is used to communicate the state of a running Pomodoro session

type Store

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

func NewStore

func NewStore(path string) (*Store, error)

func (Store) Close

func (s Store) Close() error

func (Store) CreatePomodoro

func (s Store) CreatePomodoro(tx *sql.Tx, taskID int, pomodoro Pomodoro) error

func (Store) CreateTask

func (s Store) CreateTask(tx *sql.Tx, task Task) (int, error)

func (Store) DeletePomodoros

func (s Store) DeletePomodoros(tx *sql.Tx, taskID int) error

func (Store) DeleteTask

func (s Store) DeleteTask(tx *sql.Tx, taskID int) error

func (Store) ReadPomodoros

func (s Store) ReadPomodoros(tx *sql.Tx, taskID int) ([]*Pomodoro, error)

func (Store) ReadTask

func (s Store) ReadTask(tx *sql.Tx, taskID int) (*Task, error)

func (Store) ReadTasks

func (s Store) ReadTasks(tx *sql.Tx) ([]*Task, error)

func (Store) UpdateTask

func (s Store) UpdateTask(tx *sql.Tx, taskID int, task Task) error

func (Store) With

func (s Store) With(fns ...func(tx *sql.Tx) error) error

With applies all of the given functions with a single transaction, rolling back on failure and commiting on success.

type StoreFunc

type StoreFunc func(tx *sql.Tx) error

type Task

type Task struct {
	ID      int    `json:"id"`
	Message string `json:"message"`
	// Array of completed pomodoros
	Pomodoros []*Pomodoro `json:"pomodoros"`
	// Free-form tags associated with this task
	Tags []string `json:"tags"`
	// Number of pomodoros for this task
	NPomodoros int `json:"n_pomodoros"`
	// Duration of each pomodoro
	Duration time.Duration `json:"duration"`
}

Task describes some activity

func After

func After(start time.Time, tasks []*Task) []*Task

After returns tasks that were started after the provided start time.

func Finished

func Finished(tasks []*Task) []*Task

Finished returns tasks that have completed all pomodoros.

func Unfinished

func Unfinished(tasks []*Task) []*Task

Unfinished returns tasks that have not completed all pomodoros.

func WithTag

func WithTag(tags []string, tasks []*Task) []*Task

WithTag returns tasks that have at least one of the specified tags.

type TaskRunner

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

func NewMockedTaskRunner

func NewMockedTaskRunner(task *Task, store *Store, notifier Notifier) (*TaskRunner, error)

func NewTaskRunner

func NewTaskRunner(task *Task, config *Config) (*TaskRunner, error)

func (*TaskRunner) Pause

func (t *TaskRunner) Pause()

func (*TaskRunner) SetState

func (t *TaskRunner) SetState(state State)

func (*TaskRunner) Start

func (t *TaskRunner) Start()

func (*TaskRunner) Status

func (t *TaskRunner) Status() *Status

func (*TaskRunner) TimePauseDuration

func (t *TaskRunner) TimePauseDuration() time.Duration

func (*TaskRunner) TimeRemaining

func (t *TaskRunner) TimeRemaining() time.Duration

func (*TaskRunner) Toggle

func (t *TaskRunner) Toggle()

type Wheel

type Wheel int

Wheel keeps track of an ASCII spinner

func (*Wheel) String

func (w *Wheel) String() string

type Xnotifier

type Xnotifier struct {
	*notificator.Notificator
	// contains filtered or unexported fields
}

Xnotifier can push notifications to mac, linux and windows.

func (Xnotifier) Notify

func (n Xnotifier) Notify(title, body string) error

Notify sends a notification to the OS.

Jump to

Keyboard shortcuts

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