loam

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata map[string]interface{}

Metadata aliases the flexible YAML frontmatter map.

type Note

type Note struct {
	ID       string   // Typically the filename without extension
	Metadata Metadata // Parsed YAML frontmatter
	Content  string   // The markdown body
}

Note represents a Markdown file with optional YAML frontmatter.

func Parse

func Parse(r io.Reader) (*Note, error)

Parse reads a stream and decodes it into a Note. It detects if the stream starts with a frontmatter block (delimeted by ---).

func (*Note) String

func (n *Note) String() (string, error)

String serializes the note back to Markdown with Frontmatter.

type Transaction added in v0.2.0

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

Transaction represents a multi-step operation that holds the lock.

func (*Transaction) Apply added in v0.2.0

func (tx *Transaction) Apply(msg string) error

Apply persists the transaction changes: git add + git commit + unlock.

func (*Transaction) Rollback added in v0.2.0

func (tx *Transaction) Rollback() error

Rollback undoes changes made during the transaction and releases the lock.

func (*Transaction) Write added in v0.2.0

func (tx *Transaction) Write(n *Note) error

Write saves a note to disk within the transaction. It does NOT stage the file in Git.

type Vault

type Vault struct {
	Path string
	Git  *git.Client

	Logger *slog.Logger
	// contains filtered or unexported fields
}

Vault represents a directory containing notes backed by Git.

func NewVault

func NewVault(path string, logger *slog.Logger) (*Vault, error)

NewVault creates a Vault instance rooted at the given path. It ensures the path exists and initializes the Git client.

func (*Vault) Begin added in v0.2.0

func (v *Vault) Begin() (*Transaction, error)

Begin starts a new transaction. It acquires the global lock.

func (*Vault) Delete

func (v *Vault) Delete(id string) error

Delete removes a note from the vault and stages the deletion in Git.

func (*Vault) List

func (v *Vault) List() ([]Note, error)

List returns a list of all notes in the vault. It scans the directory recursively for .md files and parses them.

func (*Vault) Read

func (v *Vault) Read(id string) (*Note, error)

Read loads a note by its ID (filename without extension). It looks for {ID}.md in the vault root.

func (*Vault) Save added in v0.2.0

func (v *Vault) Save(n *Note, msg string) error

Save is an atomic wrapper for Write+Commit.

func (*Vault) Sync

func (v *Vault) Sync() error

Sync synchronizes the vault with the remote repository. It effectively performs a git pull --rebase and git push.

Jump to

Keyboard shortcuts

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