history

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package history persists REPL input between sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileName

func FileName(label string) string

FileName returns a safe file name for the history of a connection label.

func IsSensitive

func IsSensitive(statement string) bool

IsSensitive reports whether a statement should be kept out of the history because it probably contains credentials. This is a heuristic; starting a line with a space keeps anything out for certain.

Types

type History

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

History is an append-only log of executed inputs, one entry per line with newlines escaped, stored with owner-only permissions.

func Open

func Open(path string, max int) (*History, error)

Open loads the history file at path, keeping at most max entries. A missing file is an empty history. When the file has grown well past max it is compacted.

func (*History) Add

func (h *History) Add(entry string) (bool, error)

Add appends an entry and persists it. Entries that look like they contain credentials, entries starting with a space (the shell convention for "do not record this") and immediate repeats are skipped; it reports whether the entry was recorded.

func (*History) Entries

func (h *History) Entries() []string

Entries returns the entries, oldest first.

Jump to

Keyboard shortcuts

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