bookmarks

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package bookmarks manages persistent directory bookmarks for the grut TUI. Bookmarks are stored in a separate TOML file alongside the main config to avoid conflicting writes with the read-only config loader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bookmark

type Bookmark struct {
	Path string `toml:"path"`
	Name string `toml:"name"`
}

Bookmark represents a single bookmarked directory.

type Manager

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

Manager provides thread-safe bookmark operations and persistence.

func NewManager

func NewManager(cfg config.BookmarksConfig) *Manager

NewManager creates a Manager seeded from the config's bookmark paths. Each path in cfg.Paths is converted into a Bookmark with its basename as the display name. The manager then attempts to load any previously saved bookmarks from the bookmarks file, merging them in.

func NewManagerWithDir

func NewManagerWithDir(cfg config.BookmarksConfig, configDir string) *Manager

NewManagerWithDir creates a Manager with an explicit config directory. This is useful for testing to avoid loading the user's real bookmarks.

func (*Manager) Add

func (m *Manager) Add(path string) error

Add validates the path exists and is a directory, checks for duplicates, and appends a new bookmark.

func (*Manager) Has

func (m *Manager) Has(path string) bool

Has reports whether the given path is bookmarked.

func (*Manager) List

func (m *Manager) List() []Bookmark

List returns a snapshot of all bookmarks.

func (*Manager) Remove

func (m *Manager) Remove(path string) error

Remove deletes the bookmark with the given path. Returns an error if the path is not bookmarked.

func (*Manager) Save

func (m *Manager) Save() error

Save persists the current bookmarks to the bookmarks file.

func (*Manager) SetConfigDir

func (m *Manager) SetConfigDir(dir string)

SetConfigDir overrides the config directory (used in tests).

Jump to

Keyboard shortcuts

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