clhistory

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLHistory

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

func New

func New(params CLHistoryParams) (*CLHistory, error)

func (*CLHistory) Add

func (h *CLHistory) Add(s string) error

Add adds the given string as a new history item to the in-RAM history and, if Filename in params was not empty, then also to this file. It also resets the history navigation, if any.

func (*CLHistory) Load

func (h *CLHistory) Load() error

Load loads all history from the file. If Filename in params is empty, Load is a no-op.

func (*CLHistory) Next

func (h *CLHistory) Next(s string) (item Item, hasMore bool)

Next returns what it considers the next item.

func (*CLHistory) Prev

func (h *CLHistory) Prev(s string) (item Item, hasMore bool)

Prev returns what it considers the previous item.

func (*CLHistory) Reset

func (h *CLHistory) Reset()

Reset resets the history navigation. Typically client code should call it when a user edits or aborts/accepts the command line.

type CLHistoryParams

type CLHistoryParams struct {
	// Filename is where to load the history from and write it to.  If it's
	// empty, the history is only kept in RAM and not persisted anywhere.
	Filename string
}

type HistoryDecoder

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

func NewHistoryDecoder

func NewHistoryDecoder(r io.Reader) *HistoryDecoder

func (*HistoryDecoder) Decode

func (hd *HistoryDecoder) Decode() ([]Item, error)

type Item

type Item struct {
	Time time.Time

	Str string
}

Jump to

Keyboard shortcuts

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