Documentation ¶
Overview ¶
Package store abstracts the persistent storage used by elvish.
Index ¶
- Constants
- Variables
- func DefaultDB(dbname string) (*sql.DB, error)
- func EnsureDataDir() (string, error)
- func SchemaUpToDate(db *sql.DB) bool
- type Dir
- type Store
- func (s *Store) AddCmd(cmd string) error
- func (s *Store) AddDir(d string, incFactor float64) error
- func (s *Store) Close() error
- func (s *Store) Cmd(seq int) (string, error)
- func (s *Store) Cmds(from, upto int) ([]string, error)
- func (s *Store) DelSharedVar(n string) error
- func (s *Store) FirstCmd(from int, prefix string) (int, string, error)
- func (s *Store) GetSharedVar(n string) (string, error)
- func (s *Store) IterateCmds(from, upto int, f func(string) bool) error
- func (s *Store) LastCmd(upto int, prefix string) (int, string, error)
- func (s *Store) ListDirs() ([]Dir, error)
- func (s *Store) NextCmdSeq() (int, error)
- func (s *Store) SetSharedVar(n, v string) error
Constants ¶
const SchemaVersion = 1
Variables ¶
var ErrEmptyHOME = errors.New("environment variable HOME is empty")
ErrEmptyHOME is the error returned by EnsureDataDir when the environmental variable HOME is empty.
var ErrNoMatchingCmd = errors.New("no matching command line")
ErrNoMatchingCmd is the error returned when a LastCmd or FirstCmd query completes with no result.
var ErrNoVar = errors.New("no such variable")
var Logger = util.GetLogger("[store] ")
Functions ¶
func EnsureDataDir ¶
EnsureDataDir ensures Elvish's data directory exists, creating it if necessary. It returns the path to the data directory (never with a trailing slash) and possible error.
func SchemaUpToDate ¶ added in v0.5.0
Types ¶
type Store ¶
Store is the permanent storage backend for elvish.
func NewStoreDB ¶
NewStoreDB creates a new Store with a custom database. The database must be a SQLite database.
func (*Store) DelSharedVar ¶
func (*Store) FirstCmd ¶
FirstCmd finds the first command after the given sequence number (inclusive) with the given prefix.
func (*Store) IterateCmds ¶ added in v0.5.0
func (*Store) LastCmd ¶
LastCmd finds the last command before the given sequence number (exclusive) with the given prefix.
func (*Store) ListDirs ¶
ListDirs lists all directories in the directory history. The results are ordered by scores in descending order.
func (*Store) NextCmdSeq ¶
NextCmdSeq returns the next sequence number of the command history.