Documentation
¶
Index ¶
- Constants
- Variables
- func BuildPreSelected(entries []Entry) map[string]bool
- func DefaultName(path string) string
- func ExpandEntries(entries []Entry) (map[string]bool, error)
- func HashEntry(name string) string
- func ReadFile(dir string, name string) (string, error)
- func ResolveHash(entries []Entry, prefix string) (string, error)
- type Entry
- type EntryType
- type HashTable
- type Reader
- type ResolvedFile
- type Vault
- func (v *Vault) AddDir(path, name string, recursive bool) error
- func (v *Vault) AddFile(path, name string) error
- func (v *Vault) Entries() []Entry
- func (v *Vault) Remove(name string) error
- func (v *Vault) RemoveByPath(path string) error
- func (v *Vault) ReplaceEntries(entries []Entry)
- func (v *Vault) ResolveIdentifier(id string) (string, error)
- func (v *Vault) Save() error
Constants ¶
const ConfigFilename = ".pickaxe.json"
ConfigFilename is the name of the per-project config file.
Variables ¶
Functions ¶
func BuildPreSelected ¶
BuildPreSelected builds a set of already-registered paths for TUI pre-selection.
func DefaultName ¶
DefaultName derives the short name from a file or directory path.
func ExpandEntries ¶
ExpandEntries returns a map of all concrete .md file paths covered by the given entries. File entries contribute their path directly. Dir entries are expanded (flat or recursive depending on entry.Recursive). The boolean value is always true (the map is used as a set). Unavailable files are skipped.
Types ¶
type Entry ¶
type Entry struct {
Type EntryType `json:"type"`
Path string `json:"path"`
Name string `json:"name"`
Recursive bool `json:"recursive,omitempty"`
}
Entry represents one registered file or directory.
type HashTable ¶
type HashTable struct {
// contains filtered or unexported fields
}
HashTable maps entry names to their hashes and shortest unique prefix lengths.
func NewHashTable ¶
NewHashTable builds a HashTable from a slice of entries.
func (*HashTable) ResolvePrefix ¶
ResolvePrefix finds the entry name whose hash starts with prefix. Returns ErrAmbiguousHash if multiple entries match, ErrNotFound if none.
func (*HashTable) ShortPrefixLen ¶
ShortPrefixLen returns the length of the shortest unique prefix for the named entry, capped at 8 (the display hash length).
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a thin VaultReader implementation that delegates to the package-level ListFiles and ReadFile functions, re-reading from disk each call.
func (*Reader) ListFiles ¶
func (r *Reader) ListFiles() ([]ResolvedFile, error)
type ResolvedFile ¶
ResolvedFile is a concrete file path with its display name and availability info.
func ListFiles ¶
func ListFiles(dir string) ([]ResolvedFile, error)
ListFiles opens the vault at dir and returns all resolved files. Re-reads from disk every call.
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
Vault owns a single .pickaxe.json and its mutations.
func (*Vault) AddFile ¶
AddFile registers a single file. name may be empty (defaults to filename sans ext).
func (*Vault) RemoveByPath ¶
RemoveByPath removes the entry with the given path. Returns ErrNotFound if absent.
func (*Vault) ReplaceEntries ¶
ReplaceEntries replaces all entries with the given slice.
func (*Vault) ResolveIdentifier ¶
ResolveIdentifier returns the entry name matching id by exact name first, then by hash prefix. Returns ErrAmbiguousHash or ErrNotFound on failure.