Documentation ¶
Index ¶
- Variables
- func CheckIsDir(path string) error
- func ConfigPath() string
- func DatabasePath() string
- func Dump(d Database, opts DumpOpts) interface{}
- func FindAutojumpDatabase() string
- type Database
- type DumpOpts
- type Entry
- type GobDatabase
- func (d *GobDatabase) AdjustWeight(path string, weight float64)
- func (d *GobDatabase) Dirty() bool
- func (d *GobDatabase) GetWeights() []Entry
- func (d *GobDatabase) Prune(maxEntries int, excludePatterns []string)
- func (d *GobDatabase) Remove(path string)
- func (d *GobDatabase) Replace(entries []Entry)
- func (d *GobDatabase) Save(w io.Writer) error
- func (d *GobDatabase) Search(count int, needles ...string) []Entry
- type Options
- type Searcher
- type StringCompare
- type Weight
Constants ¶
This section is empty.
Variables ¶
var ErrNotDir = errors.New("path is not a directory")
ErrNotDir is returned by CheckIsDir when the path is not a directory.
Functions ¶
func CheckIsDir ¶
CheckIsDir checks that the input path is a directory.
func DatabasePath ¶
func DatabasePath() string
DatabasePath looks up the full path to the database file.
func FindAutojumpDatabase ¶
func FindAutojumpDatabase() string
Types ¶
type Database ¶
type Database interface { // Adjust the weight for a given path; weight can be positive or // negative. AdjustWeight(string, float64) // Does the database need to be saved? // TODO: this is a little hacky. Dirty() bool // Return the list of weights in the database. GetWeights() []Entry // Remove a path from the database. Remove(string) // Replace the current weights. Replace([]Entry) // Prune the database. Prune(int, []string) // Save the database to a writer. Save(io.Writer) error // Search for a query and find the best match. // TODO: allow this to return multiple results. Search(int, ...string) []Entry }
Database represents the database.
type DumpOpts ¶
type DumpOpts struct {
Short bool // shorten output paths by abbreviating tilde
}
DumpOpts represents the dump options
type Entry ¶
type Entry struct { Path string `json:"path"` Weight float64 `json:"weight"` UpdatedAt time.Time `json:"time,string"` }
Entry represents a database entry.
type GobDatabase ¶
type GobDatabase struct { Weights weightMap // map of entry to weight // contains filtered or unexported fields }
GobDatabase represents the database.
func NewGobDatabase ¶
func NewGobDatabase(r io.Reader, opts Options) *GobDatabase
NewGobDatabase loads a database file.
func (*GobDatabase) AdjustWeight ¶
func (d *GobDatabase) AdjustWeight(path string, weight float64)
AdjustWeight adjusts the weight of a path. The adjusted weight value is returned.
func (*GobDatabase) GetWeights ¶
func (d *GobDatabase) GetWeights() []Entry
Dump prints the database to the specified writer.
func (*GobDatabase) Prune ¶
func (d *GobDatabase) Prune(maxEntries int, excludePatterns []string)
Prune removes entries from the database that no longer exist.
func (*GobDatabase) Remove ¶
func (d *GobDatabase) Remove(path string)
Remove removes a path from the database.
func (*GobDatabase) Replace ¶
func (d *GobDatabase) Replace(entries []Entry)
Replace replaces the underlying weight map.
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
Searcher implements the matching algorithm.
func NewSearcher ¶
NewSearcher creates a new searcher instance.
type StringCompare ¶
StringCompare is a string comparison function.