lock

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package lock marks journal entries as locked to prevent re-export and manages multipart files.

Index

Constants

View Source
const LockedFrontmatterLine = session.FrontmatterLockedLine

LockedFrontmatterLine is the YAML line inserted into frontmatter when a journal entry is locked.

Variables

This section is empty.

Functions

func FrontmatterHasLocked

func FrontmatterHasLocked(path string) bool

FrontmatterHasLocked reads a journal file and returns true if its YAML frontmatter contains a "locked:" line with a truthy value.

Parameters:

  • path: Absolute path to the journal .md file

Returns:

  • bool: True if frontmatter contains "locked: true"

func MatchJournalFiles

func MatchJournalFiles(
	journalDir string,
	patterns []string,
	all bool,
) ([]string, error)

MatchJournalFiles returns journal .md filenames matching the given patterns. If all is true, returns every .md file in the directory. Multipart files (base + -pN parts) are included when the base matches.

Parameters:

  • journalDir: Path to the journal directory
  • patterns: Slug, date, or short-ID substrings to match
  • all: If true, return all .md files

Returns:

  • []string: Matching filenames (basename only)
  • error: Non-nil on I/O failure

func MultipartBase

func MultipartBase(filename string) string

MultipartBase returns the base name for a potentially multipart file. For "2026-01-21-slug-abc12345-p2.md" it returns "2026-01-21-slug-abc12345.md". For non-multipart files, returns the filename as-is.

Parameters:

  • filename: Journal entry filename

Returns:

  • string: Base filename (without -pN suffix)

func RunLockUnlock

func RunLockUnlock(
	cmd *cobra.Command,
	args []string,
	all, lock bool,
) error

RunLockUnlock handles both lock and unlock commands.

Parameters:

  • cmd: Cobra command for output
  • args: Patterns to match against journal filenames
  • all: If true, apply to all journal entries
  • lock: True for lock, false for unlock

Returns:

  • error: Non-nil on validation or I/O failure

func UpdateLockFrontmatter

func UpdateLockFrontmatter(path string, lock bool)

UpdateLockFrontmatter inserts or removes the "locked: true" line in a journal file's YAML frontmatter. The state file is the source of truth; this is for human visibility only.

Parameters:

  • path: Absolute path to the journal .md file
  • lock: True to insert, false to remove

Types

This section is empty.

Jump to

Keyboard shortcuts

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