state

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRef = errors.New("not a valid id or index")

ErrBadRef — argument is neither a valid id nor a resolvable index.

View Source
var ErrNoRecentSearch = errors.New("no recent search; provide a full 64-char id")

ErrNoRecentSearch — index used but no last-search.json exists.

Functions

func ResolveRef

func ResolveRef(arg string) (string, error)

ResolveRef turns a CLI argument into a snippet id.

  • 64-char lowercase hex -> id itself
  • non-negative integer < 1000 -> index into last-search hits
  • anything else -> ErrBadRef

func Save

func Save(query string, hits []api.Hit) error

Save overwrites last-search.json with the given query+hits.

Types

type LastSearch

type LastSearch struct {
	Query     string    `json:"query"`
	Timestamp int64     `json:"timestamp"`
	Hits      []api.Hit `json:"hits"`
}

LastSearch is the persisted last-search.json document.

func Load

func Load() (*LastSearch, error)

Load reads last-search.json. Returns ErrNoRecentSearch if absent.

Jump to

Keyboard shortcuts

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