store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package store abstracts the persistent storage used by elvish.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyHOME = errors.New("environment variable HOME is empty")

ErrEmptyHOME is the error returned by EnsureDataDir when the environmental variable HOME is empty.

View Source
var ErrNoMatchingCmd = errors.New("no matching command line")

ErrNoMatchingCmd is the error returned when a LastCmd or FirstCmd query completes with no result.

View Source
var ErrNoVar = errors.New("no such variable")

Functions

func DataDir

func DataDir() (string, error)

func DefaultDB

func DefaultDB(dbname string) (*sql.DB, error)

DefaultDB returns the default database for storage.

func EnsureDataDir

func EnsureDataDir() (string, error)

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.

Types

type Dir

type Dir struct {
	Path  string
	Score float64
}

Dir is an entry in the directory history.

type Store

type Store struct {
	Waits sync.WaitGroup
	// contains filtered or unexported fields
}

Store is the permanent storage backend for elvish.

func NewStore

func NewStore(dbname string) (*Store, error)

NewStore creates a new Store with the default database.

func NewStoreDB

func NewStoreDB(db *sql.DB) (*Store, error)

NewStoreDB creates a new Store with a custom database. The database must be a SQLite database.

func (*Store) AddCmd

func (s *Store) AddCmd(cmd string) error

AddCmd adds a new command to the command history.

func (*Store) AddDir

func (s *Store) AddDir(d string, incFactor float64) error

AddDir adds a directory to the directory history.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Cmd

func (s *Store) Cmd(seq int) (string, error)

Cmd queries the command history item with the specified sequence number.

func (*Store) Cmds

func (s *Store) Cmds(from, upto int) ([]string, error)

func (*Store) DelSharedVar

func (s *Store) DelSharedVar(n string) error

func (*Store) FindDirs

func (s *Store) FindDirs(p string) ([]Dir, error)

FindDirs finds directories containing a given substring. The results are ordered by scores in descending order.

func (*Store) FindDirsLoose

func (s *Store) FindDirsLoose(p string) ([]Dir, error)

FindDirsLoose finds directories matching a given pattern. The results are ordered by scores in descending order.

The pattern is first split on slashes, and have % attached to both sides of the parts. For instance, a/b becomes %a%/%b%, so it matches /1a1/2b2 as well as /home/xiaq/1a1/what/2b2.

func (*Store) FirstCmd

func (s *Store) FirstCmd(from int, prefix string, uniq bool) (int, string, error)

FirstCmd finds the first command after the given sequence number (inclusive) with the given prefix.

func (*Store) GetSharedVar

func (s *Store) GetSharedVar(n string) (string, error)

func (*Store) LastCmd

func (s *Store) LastCmd(upto int, prefix string, uniq bool) (int, string, error)

LastCmd finds the last command before the given sequence number (exclusive) with the given prefix.

func (*Store) ListDirs

func (s *Store) ListDirs() ([]Dir, error)

ListDirs lists all directories in the directory history. The results are ordered by scores in descending order.

func (*Store) NextCmdSeq

func (s *Store) NextCmdSeq() (int, error)

NextCmdSeq returns the next sequence number of the command history.

func (*Store) SetSharedVar

func (s *Store) SetSharedVar(n, v string) error

Jump to

Keyboard shortcuts

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