pomo

package
v0.0.0-...-56f1659 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "undefined"

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func FormatStatus

func FormatStatus(status Status) string

func InitDB

func InitDB(db *Store) error

func LoadConfig

func LoadConfig(configPath string, config *Config) error

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

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) 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.

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