database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Wildcard  = "?"
	TrashTag  = "coach.trash.983476" // just something arbitrary that is unlikely to be used by anything else
	FilePerms = 0660
)

Variables

View Source
var (
	HistoryBucket    = []byte("history")
	SavedCmdsBucket  = []byte("commands")
	IgnoreBucket     = []byte("ignore")
	IgnoreWordBucket = []byte("ignore-word")

	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
)

Functions

func CleanseCommand

func CleanseCommand(command string) string

CleanseCommand converts a command to what it would look like in the database

Types

type BoltDB

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

func NewBoltDB

func NewBoltDB(path string, readonly bool) (b *BoltDB, err error)

func (*BoltDB) CheckDupeCmds

func (b *BoltDB) CheckDupeCmds(command string, count int) (countReached bool)

func (*BoltDB) Close

func (b *BoltDB) Close() error

Close closes the bolt db file.

func (*BoltDB) DeleteScript

func (b *BoltDB) DeleteScript(alias []byte) error

func (*BoltDB) GetRecent

func (b *BoltDB) GetRecent(tty, username string, count int) ([]models.HistoryRecord, error)

GetRecent retrieves the last count (arg) lines of history from specified tty (arg).

func (*BoltDB) GetScript

func (b *BoltDB) GetScript(alias []byte) (command *models.DocumentedScript)

func (*BoltDB) IgnoreCommand

func (b *BoltDB) IgnoreCommand(command, username string) (err error)

func (*BoltDB) IgnoreWord added in v1.2.0

func (b *BoltDB) IgnoreWord(word, username string) (err error)

func (*BoltDB) Init added in v1.2.0

func (b *BoltDB) Init() error

func (*BoltDB) PruneHistory

func (b *BoltDB) PruneHistory(max int) error

func (*BoltDB) QueryHistory added in v1.3.0

func (b *BoltDB) QueryHistory(regex *regexp.Regexp, username string, all bool) ([]models.HistoryRecord, error)

func (*BoltDB) QueryScripts

func (b *BoltDB) QueryScripts(tags ...string) ([]models.DocumentedScript, error)

func (*BoltDB) Save

func (b *BoltDB) Save(id []byte, instance interface{}, overwrite bool) (err error)

func (*BoltDB) SaveBatch added in v1.2.0

func (b *BoltDB) SaveBatch(toSave <-chan HasID, bucket []byte) <-chan error

func (*BoltDB) ShouldIgnoreCommand added in v1.2.0

func (b *BoltDB) ShouldIgnoreCommand(command, username string) (yes bool)

func (*BoltDB) ShouldIgnoreWord added in v1.2.0

func (b *BoltDB) ShouldIgnoreWord(word, username string) (yes bool)

func (*BoltDB) UnignoreCommand

func (b *BoltDB) UnignoreCommand(command, username string) (err error)

func (*BoltDB) UnignoreWord added in v1.2.0

func (b *BoltDB) UnignoreWord(word, username string) (err error)

type HasID added in v1.2.0

type HasID interface {
	GetId() []byte
}

Jump to

Keyboard shortcuts

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