paths

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package paths provides a shared prefix resolver for named directory paths. Components that need to resolve prefixed paths (kb:, scratchpad:, etc.) use a single Resolver instance built from configuration at startup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandHome

func ExpandHome(path string) string

ExpandHome replaces a leading ~ with the user's home directory.

Types

type Resolver

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

Resolver maps named prefixes to absolute directory paths. It is nil-safe: calling Resolver.Resolve on a nil *Resolver returns the input path unchanged, matching the nil-safe pattern used by the event bus.

func New

func New(prefixes map[string]string) *Resolver

New creates a Resolver from a prefix-to-directory map. Keys are prefix names without the trailing colon (e.g., "kb", not "kb:"). Home directory tildes (~) in values are expanded at construction time. Returns nil if the map is empty or nil.

func (*Resolver) HasPrefix

func (r *Resolver) HasPrefix(path string) bool

HasPrefix reports whether the path starts with a registered prefix.

func (*Resolver) Prefixes

func (r *Resolver) Prefixes() []string

Prefixes returns the registered prefix names sorted alphabetically, without trailing colons. Useful for documentation and help output.

func (*Resolver) Resolve

func (r *Resolver) Resolve(path string) (string, error)

Resolve expands a prefixed path to an absolute path. If no registered prefix matches, the original path is returned unchanged. A bare prefix (e.g., "kb:" with no trailing path) returns the root directory for that prefix.

Jump to

Keyboard shortcuts

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