tui

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBinaryContent

func IsBinaryContent(content string) bool

IsBinaryContent checks if content appears to be binary

func ReadZipFile

func ReadZipFile(zipPath, filePath, projectName string) (string, error)

ReadZipFile extracts the contents of a file from a zip archive

func Run

func Run(version string) error

Run starts the TUI

Types

type DiffLine

type DiffLine struct {
	LineNum1 int    // Line number in version 1 (0 if added)
	LineNum2 int    // Line number in version 2 (0 if deleted)
	Type     rune   // '+' added, '-' deleted, ' ' unchanged
	Content  string // Line content
}

DiffLine represents a single line in the diff output

type DiffResult

type DiffResult struct {
	Version1 string
	Version2 string
	Changes  []FileChange
	Added    int
	Modified int
	Deleted  int
}

DiffResult contains the comparison between two backup versions

func ComputeDiff

func ComputeDiff(cfg *config.Config, project, version1, version2 string) (*DiffResult, error)

ComputeDiff compares two backup versions and returns the differences

type FileChange

type FileChange struct {
	Path   string
	Status rune // 'M' modified, 'A' added, 'D' deleted
	Size1  int64
	Size2  int64
}

FileChange represents a change between two versions

type FileDiffResult

type FileDiffResult struct {
	Path     string
	Version1 string
	Version2 string
	Lines    []DiffLine
	IsBinary bool
	Error    string
}

FileDiffResult contains the line-by-line diff of a single file

func ComputeFileDiff

func ComputeFileDiff(cfg *config.Config, project, version1, version2, filePath string, status rune) (*FileDiffResult, error)

ComputeFileDiff computes the line-by-line diff between two versions of a file

type Model

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

Model is the main TUI model

func NewModel

func NewModel(version string) (*Model, error)

NewModel creates a new TUI model with default service.

func NewModelWithConfig

func NewModelWithConfig(cfg *config.Config, svc ports.TUIService) *Model

NewModelWithConfig creates a new TUI model with a provided config and service. This is useful for testing with pre-configured state.

func NewModelWithService

func NewModelWithService(version string, svc ports.TUIService) (*Model, error)

NewModelWithService creates a new TUI model with a custom service. This allows dependency injection for testing.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the model

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages

func (*Model) View

func (m *Model) View() string

View renders the UI

type ProjectItem

type ProjectItem struct {
	Name        string
	Path        string
	SourceLabel string
	SourceIcon  string
	SourceType  string // "git" or "sensitive"
	Versions    int
	LastBackup  time.Time
	TotalSize   int64
}

ProjectItem represents a project in the list

type SnapshotItem added in v1.0.0

type SnapshotItem struct {
	ID    string
	Time  time.Time
	Paths []string
	Tags  []string
}

SnapshotItem represents a restic snapshot in the list

type VersionItem

type VersionItem struct {
	File      string
	Size      int64
	FileCount int
	GitHead   string
	CreatedAt time.Time
}

VersionItem represents a backup version

type View

type View int

View represents the current view state

const (
	ProjectsView View = iota
	VersionsView
	SnapshotsView   // View for restic snapshots (sensitive sources)
	DiffSelectView  // Selecting versions to compare
	DiffResultView  // Showing diff results (file list)
	FileDiffView    // Showing actual file content diff
	SettingsView    // Settings/configuration view
	MoveInputView   // Folder picker for move path
	MoveConfirmView // Confirmation before moving
)

Jump to

Keyboard shortcuts

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