commands

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(s *store.Store, days int) error

func Copy added in v1.7.0

func Copy(s *store.Store, all bool, global bool, project string, indexStr string) error

Copy retrieves a scratch by index and copies its content to the clipboard

func Create

func Create(s *store.Store, project string, content []byte) error

func CreateWithTitle added in v1.3.0

func CreateWithTitle(s *store.Store, project string, content []byte, providedTitle string) error

CreateWithTitle creates a scratch with an optional pre-defined title

func CreateWithTitleAndContent added in v1.5.2

func CreateWithTitleAndContent(s *store.Store, project string, title string, initialContent []byte) error

CreateWithTitleAndContent creates a scratch with a title and optional initial content

func Delete

func Delete(s *store.Store, all bool, global bool, project string, indexStr string) error

func Export added in v1.8.1

func Export(s *store.Store, all, global bool, project string, ids []string, format string) error

Export exports scratches to files in the specified format

func GetScratchByIndex added in v1.2.0

func GetScratchByIndex(s *store.Store, all, global bool, project string, indexStr string) (*store.Scratch, error)

func Ls

func Ls(s *store.Store, all, global bool, project string) []store.Scratch

func Open

func Open(s *store.Store, all bool, global bool, project string, indexStr string) error

func OpenLazy added in v1.5.3

func OpenLazy(s *store.Store, all bool, global bool, project string, indexStr string) error

OpenLazy opens a scratch in the editor and exits immediately (non-blocking)

func Peek

func Peek(s *store.Store, all, global bool, project string, indexStr string, lines int) (string, error)

func Pin added in v1.8.0

func Pin(s *store.Store, all, global bool, project string, id string) error

Pin marks a scratch as pinned

func ReadContentFromPipe

func ReadContentFromPipe() []byte

ReadContentFromPipe checks if stdin is a pipe and reads its content

func ReadContentFromPipeWithReader added in v1.0.0

func ReadContentFromPipeWithReader(reader io.Reader) []byte

ReadContentFromPipeWithReader reads content from a pipe using the provided reader This function is exported to allow for easier testing with mock readers

func ResolveScratchID added in v1.8.0

func ResolveScratchID(s *store.Store, all, global bool, project string, id string) (*store.Scratch, error)

ResolveScratchID resolves various ID formats (index, pinned index, hash) to a scratch

func Search(s *store.Store, all, global bool, project, term string) ([]store.Scratch, error)

func Unpin added in v1.8.0

func Unpin(s *store.Store, all, global bool, project string, id string) error

Unpin removes the pinned status from a scratch

func View

func View(s *store.Store, all, global bool, project string, indexStr string) (string, error)

Types

type MissingFile added in v1.5.0

type MissingFile struct {
	ID        string    `json:"id"`
	Project   string    `json:"project"`
	Title     string    `json:"title"`
	CreatedAt time.Time `json:"created_at"`
}

MissingFile represents a metadata entry without a corresponding file

type NukeResult added in v1.2.0

type NukeResult struct {
	DeletedCount int
	Scope        string
	ProjectName  string
}

NukeResult contains the result of a nuke operation

func Nuke added in v1.2.0

func Nuke(s *store.Store, all bool, project string) (*NukeResult, error)

Nuke deletes all scratches in the specified scope

type OrphanedFile added in v1.5.0

type OrphanedFile struct {
	ID      string    `json:"id"`
	Path    string    `json:"path"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"mod_time"`
	Title   string    `json:"title"`   // Extracted from content
	Preview string    `json:"preview"` // First few lines
}

OrphanedFile represents a file found on disk without metadata

type PathResult added in v1.1.0

type PathResult struct {
	Path string `json:"path"`
}

PathResult contains the path information for a scratch

func Path added in v1.1.0

func Path(s *store.Store, all bool, global bool, project string, indexStr string) (*PathResult, error)

Path returns the full path to a scratch file

type RecoveredFile added in v1.5.0

type RecoveredFile struct {
	ID        string    `json:"id"`
	Project   string    `json:"project"`
	Title     string    `json:"title"`
	CreatedAt time.Time `json:"created_at"`
	Source    string    `json:"source"` // "orphaned" or "reconstructed"
}

RecoveredFile represents a successfully recovered file

type RecoveryError added in v1.5.0

type RecoveryError struct {
	Type    string `json:"type"`
	Message string `json:"message"`
	FileID  string `json:"file_id,omitempty"`
}

RecoveryError represents an error during recovery

type RecoveryOptions added in v1.5.0

type RecoveryOptions struct {
	DryRun         bool   // Don't make changes, just report
	RecoverOrphans bool   // Recover orphaned files
	CleanMissing   bool   // Remove metadata entries without files
	DefaultProject string // Project to use for orphaned files (default: "recovered")
}

RecoveryOptions configures the recovery behavior

type RecoveryResult added in v1.5.0

type RecoveryResult struct {
	// Orphaned files found (files without metadata entries)
	OrphanedFiles []OrphanedFile `json:"orphaned_files"`

	// Metadata entries without files
	MissingFiles []MissingFile `json:"missing_files"`

	// Successfully recovered files
	RecoveredFiles []RecoveredFile `json:"recovered_files"`

	// Errors encountered during recovery
	Errors []RecoveryError `json:"errors"`

	// Summary statistics
	Summary RecoverySummary `json:"summary"`
}

RecoveryResult contains the results of a recovery operation

func Recover added in v1.5.0

func Recover(s *store.Store, options RecoveryOptions) (*RecoveryResult, error)

Recover performs a recovery operation on the scratch store

type RecoverySummary added in v1.5.0

type RecoverySummary struct {
	TotalOrphaned  int       `json:"total_orphaned"`
	TotalMissing   int       `json:"total_missing"`
	TotalRecovered int       `json:"total_recovered"`
	TotalErrors    int       `json:"total_errors"`
	StartTime      time.Time `json:"start_time"`
	EndTime        time.Time `json:"end_time"`
	Duration       string    `json:"duration"`
}

RecoverySummary contains summary statistics

type ScratchWithIndex added in v1.2.0

type ScratchWithIndex struct {
	store.Scratch
	Index int `json:"index"`
}

ScratchWithIndex wraps a Scratch with its positional index

func SearchWithIndices added in v1.2.0

func SearchWithIndices(s *store.Store, all, global bool, project, term string) ([]ScratchWithIndex, error)

SearchWithIndices performs a search and returns results with their correct positional indices

type ShowDataFileResult added in v1.8.5

type ShowDataFileResult struct {
	Path string `json:"path"`
}

ShowDataFileResult contains the data file path information

func ShowDataFile added in v1.8.5

func ShowDataFile(s *store.Store) (*ShowDataFileResult, error)

ShowDataFile returns the path to the data file used by padz

type TestSetup added in v1.2.0

type TestSetup struct {
	Store   *store.Store
	Config  *config.Config
	Cleanup func()
}

TestSetup contains everything needed for testing commands

func SetupCommandTest added in v1.2.0

func SetupCommandTest(t *testing.T) *TestSetup

SetupCommandTest prepares a test environment for command tests

func (*TestSetup) ReadScratchFile added in v1.2.0

func (ts *TestSetup) ReadScratchFile(t *testing.T, id string) []byte

ReadScratchFile reads a scratch file from the test filesystem

func (*TestSetup) WriteScratchFile added in v1.2.0

func (ts *TestSetup) WriteScratchFile(t *testing.T, id string, content []byte)

WriteScratchFile writes a scratch file content in the test filesystem

Jump to

Keyboard shortcuts

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