history

package
v0.0.0-...-d1114cd Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package history provides utilities for the command history.

Index

Constants

This section is empty.

Variables

View Source
var ErrEndOfHistory = errors.New("end of history")

Functions

This section is empty.

Types

type Fuser

type Fuser struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

Fuser provides a unified view into a shared storage-backed command history and per-session history.

func NewFuser

func NewFuser(store Store) (*Fuser, error)

func (*Fuser) AddCmd

func (f *Fuser) AddCmd(cmd string) error

func (*Fuser) AllCmds

func (f *Fuser) AllCmds() ([]string, error)

func (*Fuser) SessionCmds

func (f *Fuser) SessionCmds() []string

func (*Fuser) Walker

func (f *Fuser) Walker(prefix string) *Walker

type Store

type Store interface {
	NextCmdSeq() (int, error)
	AddCmd(cmd string) (int, error)
	Cmds(from, upto int) ([]string, error)
	PrevCmd(upto int, prefix string) (int, string, error)
}

Store is the interface of the storage backend.

type Walker

type Walker struct {
	// contains filtered or unexported fields
}

Walker is used for walking through history entries with a given (possibly empty) prefix, skipping duplicates entries.

func NewWalker

func NewWalker(store Store, upper int, cmds []string, seqs []int, prefix string) *Walker

func (*Walker) CurrentCmd

func (w *Walker) CurrentCmd() string

CurrentSeq returns the content of the current entry.

func (*Walker) CurrentSeq

func (w *Walker) CurrentSeq() int

CurrentSeq returns the sequence number of the current entry.

func (*Walker) Next

func (w *Walker) Next() (int, string, error)

Next reverses Prev.

func (*Walker) Prefix

func (w *Walker) Prefix() string

Prefix returns the prefix of the commands that the walker walks through.

func (*Walker) Prev

func (w *Walker) Prev() (int, string, error)

Prev walks to the previous matching history entry, skipping all duplicates.

Jump to

Keyboard shortcuts

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