histree

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package histree provides core functionality for shell history management

Index

Constants

View Source
const (
	Version = "v0.3.5"
)

Version information

Variables

This section is empty.

Functions

func WriteEntries

func WriteEntries(entries []HistoryEntry, w io.Writer, format OutputFormat) error

WriteEntries writes history entries to the provided writer using the specified format

Types

type DB

type DB struct {
	*sql.DB
}

DB represents a histree database connection

func OpenDB

func OpenDB(dbPath string) (*DB, error)

OpenDB initializes and returns a new database connection

func (*DB) AddEntry

func (db *DB) AddEntry(entry *HistoryEntry) error

AddEntry adds a new command history entry to the database

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) GetEntries

func (db *DB) GetEntries(limit int, currentDir string) ([]HistoryEntry, error)

GetEntries retrieves command history entries from the database

func (*DB) UpdatePaths added in v0.3.5

func (db *DB) UpdatePaths(oldPath, newPath string) (int64, error)

UpdatePaths updates directory paths in history entries from oldPath to newPath

type HistoryEntry

type HistoryEntry struct {
	Command   string    `json:"command"`
	Directory string    `json:"directory"`
	Timestamp time.Time `json:"timestamp"`
	ExitCode  int       `json:"exit_code"`
	Hostname  string    `json:"hostname,omitempty"`
	ProcessID int       `json:"process_id,omitempty"` // The process ID of the shell that executed the command
}

HistoryEntry represents a shell command history entry

type OutputFormat

type OutputFormat string

OutputFormat defines how history entries are formatted when displayed

const (
	// FormatJSON outputs entries as JSON objects
	FormatJSON OutputFormat = "json"
	// FormatSimple outputs only the command
	FormatSimple OutputFormat = "simple"
	// FormatVerbose outputs entries with timestamp, directory and exit code
	FormatVerbose OutputFormat = "verbose"
)

Jump to

Keyboard shortcuts

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