entry

package
v0.0.0-...-d277e4d Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package entry defines the core bullet journal entry model.

Index

Constants

View Source
const (
	CurrentSchema = "v1"
)

CurrentSchema identifies the persisted entry schema version.

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(v time.Time) string

FormatTime formats the time as RFC3339Nano.

func NormalizeDependsOnIDs

func NormalizeDependsOnIDs(ids []string) []string

NormalizeDependsOnIDs returns canonical depends_on IDs: trim/dedupe/sort.

func NormalizeLabels

func NormalizeLabels(labels []string) []string

NormalizeLabels returns canonical labels: trim/lowercase/dedupe/sort.

func ParseTime

func ParseTime(v string) (time.Time, error)

ParseTime parses RFC3339 timestamps used in persisted entries.

Types

type Entry

type Entry struct {
	ID         string          `json:"-"` // do not json. ID is the filename.
	Bullet     glyph.Bullet    `json:"bullet"`
	Schema     string          `json:"schema"`
	Created    Timestamp       `json:"created"`
	Collection string          `json:"collection"`
	On         *Timestamp      `json:"on,omitempty"`
	Signifier  glyph.Signifier `json:"signifier,omitempty"`
	Message    string          `json:"message,omitempty"`
	Labels     []string        `json:"labels,omitempty"`
	DependsOn  []string        `json:"depends_on,omitempty"`
	ParentID   string          `json:"parent_id,omitempty"`
	Immutable  bool            `json:"immutable,omitempty"`
	History    []HistoryRecord `json:"history,omitempty"`
}

Entry represents a single bullet journal entry.

func New

func New(collection string, bullet glyph.Bullet, message string) *Entry

New constructs a new entry for the provided collection.

func (*Entry) AddDependsOn

func (e *Entry) AddDependsOn(ids []string)

AddDependsOn merges dependency IDs into the current canonicalized set.

func (*Entry) AddLabels

func (e *Entry) AddLabels(labels []string)

AddLabels merges labels into the current canonicalized set.

func (*Entry) CloneToCollection

func (e *Entry) CloneToCollection(collection string) *Entry

CloneToCollection creates a deep copy destined for the provided collection while preserving bullet, signifier, message, and parent linkage.

func (*Entry) Complete

func (e *Entry) Complete()

Complete marks the entry as completed.

func (*Entry) EnsureHistorySeed

func (e *Entry) EnsureHistorySeed()

EnsureHistorySeed populates a default history record for legacy entries that predate the history field.

func (*Entry) LastCompletionTime

func (e *Entry) LastCompletionTime() (time.Time, bool)

LastCompletionTime reports the most recent timestamp the entry was completed.

func (*Entry) Lock

func (e *Entry) Lock()

Lock marks the entry immutable.

func (*Entry) Move

func (e *Entry) Move(bullet glyph.Bullet, collection string) *Entry

Move clones the entry into a new collection and marks the original as moved.

func (*Entry) NormalizeDependsOn

func (e *Entry) NormalizeDependsOn()

NormalizeDependsOn canonicalizes depends_on IDs in place: trim/dedupe/sort.

func (*Entry) NormalizeLabels

func (e *Entry) NormalizeLabels()

NormalizeLabels canonicalizes labels in place: trim/lowercase/dedupe/sort.

func (*Entry) RemoveDependsOn

func (e *Entry) RemoveDependsOn(ids []string)

RemoveDependsOn removes matching dependency IDs from the canonicalized set.

func (*Entry) RemoveLabels

func (e *Entry) RemoveLabels(labels []string)

RemoveLabels removes matching labels from the canonicalized set.

func (*Entry) SetDependsOn

func (e *Entry) SetDependsOn(ids []string)

SetDependsOn replaces dependency IDs with the canonicalized input.

func (*Entry) SetLabels

func (e *Entry) SetLabels(labels []string)

SetLabels replaces labels with the canonicalized input.

func (*Entry) Strike

func (e *Entry) Strike()

Strike marks the entry as irrelevant.

func (*Entry) String

func (e *Entry) String() string

func (*Entry) Title

func (e *Entry) Title() string

Title returns the entry's collection name for presentation.

func (*Entry) Unlock

func (e *Entry) Unlock()

Unlock removes the immutable flag.

type HistoryAction

type HistoryAction string

HistoryAction describes a recorded change in an entry's history.

const (
	// HistoryActionAdded indicates the entry was created.
	HistoryActionAdded HistoryAction = "added"
	// HistoryActionMoved indicates the entry was migrated to another collection.
	HistoryActionMoved HistoryAction = "moved"
	// HistoryActionCompleted indicates the entry was completed.
	HistoryActionCompleted HistoryAction = "completed"
	// HistoryActionStruck indicates the entry was struck out as irrelevant.
	HistoryActionStruck HistoryAction = "struck"
)

type HistoryRecord

type HistoryRecord struct {
	Timestamp Timestamp     `json:"timestamp"`
	Action    HistoryAction `json:"action"`
	From      string        `json:"from,omitempty"`
	To        string        `json:"to,omitempty"`
}

HistoryRecord captures a single history event for an entry.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp wraps time.Time with helper methods for journaling logic.

func (*Timestamp) MarshalJSON

func (t *Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON serializes the timestamp into RFC3339 JSON.

func (Timestamp) SameDay

func (t Timestamp) SameDay(then time.Time) bool

SameDay reports whether the timestamp falls on the same local day as then.

func (Timestamp) SameMonth

func (t Timestamp) SameMonth(then time.Time) bool

SameMonth reports whether the timestamp falls in the same month/year as then.

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a timestamp from its JSON encoding.

Jump to

Keyboard shortcuts

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