cmd

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute() error

func SetVersion added in v0.3.3

func SetVersion(v string)

SetVersion sets the version for the CLI (called from main with ldflags value)

Types

type Action

type Action struct {
	Name        string       `yaml:"name"`
	Description string       `yaml:"description"`
	Script      string       `yaml:"script"`
	Condition   string       `yaml:"condition,omitempty"` // Shell command, runs if exit 0
	Input       *InputConfig `yaml:"input,omitempty"`
}

Action represents a new or remove action

type AheadBehindCount

type AheadBehindCount struct {
	Ahead  int
	Behind int
}

AheadBehindCount represents commits ahead/behind remote

type BranchInfo added in v0.3.5

type BranchInfo struct {
	Branch       string
	CommitsAhead int
	WorktreePath string
	HasWIP       bool
}

BranchInfo holds metadata about a branch for display and selection

type ChangedFile added in v0.3.4

type ChangedFile struct {
	Path    string // File path relative to repo root
	Status  string // M=Modified, A=Added, D=Deleted, R=Renamed, C=Copied
	OldPath string // For renames/copies, the original path
}

ChangedFile represents a file that has been modified, added, or deleted

type Config

type Config struct {
	New    []Action `yaml:"new,omitempty"`
	Remove []Action `yaml:"remove,omitempty"`
}

Config represents the .git-wt.yaml configuration

type DiffChange added in v0.3.4

type DiffChange struct {
	OldStart int // Starting line in old file (1-based)
	OldCount int // Number of lines affected in old file
	NewStart int // Starting line in new file (1-based)
	NewCount int // Number of lines affected in new file
}

DiffChange represents a change identified from unified diff

type DiffHunk added in v0.3.4

type DiffHunk struct {
	StartLine int // Starting line index in Lines
	EndLine   int // Ending line index (exclusive)
}

DiffHunk represents a block/hunk in the diff

type DiffLine added in v0.3.4

type DiffLine struct {
	LeftNum   int      // Line number on left (0 = no line)
	LeftText  string   // Content on left side
	RightNum  int      // Line number on right (0 = no line)
	RightText string   // Content on right side
	Type      LineType // Type of line
}

DiffLine represents a single line in a side-by-side diff

type DiffMode added in v0.3.4

type DiffMode int

DiffMode represents what type of diff to show

const (
	DiffModeBase     DiffMode = iota // Compare against base branch
	DiffModeStaged                   // Show staged changes
	DiffModeUnstaged                 // Show unstaged changes
)

type DiffModeView added in v0.3.4

type DiffModeView struct {
	Cursor     int
	BaseBranch string
}

DiffModeView holds the state for the diff mode selection

type DiffView added in v0.3.4

type DiffView struct {
	File          *ChangedFile
	Lines         []DiffLine
	Hunks         []DiffHunk // List of hunks for block navigation
	CurrentHunk   int        // Currently highlighted hunk index
	ScrollOffset  int
	TermWidth     int
	TermHeight    int
	LeftWidth     int
	RightWidth    int
	ShowFullFile  bool       // Toggle: false = changes only (default), true = full file
	FullFileLines []DiffLine // Full file side-by-side view
	FullFileHunks []DiffHunk // Hunk positions in full file view
	// For hunk staging/unstaging
	Mode         DiffMode
	WorktreePath string
	BaseBranch   string
	RawDiff      string // Original unified diff text for hunk extraction
}

DiffView holds the state for the diff viewer

type FileListView added in v0.3.4

type FileListView struct {
	Files        []ChangedFile
	Cursor       int
	BaseBranch   string
	Title        string
	Mode         DiffMode // Track which mode we're in for stage/unstage
	WorktreePath string   // Path for git operations
}

FileListView holds the state for the file list

type InputConfig

type InputConfig struct {
	Type    string   `yaml:"type"`              // "boolean", "option", "text"
	Message string   `yaml:"message"`           // Prompt message (can be multiline)
	Options []Option `yaml:"options,omitempty"` // For "option" type only
}

InputConfig represents user input configuration for an action

type Key added in v0.3.4

type Key int

Key represents a parsed keypress

const (
	KeyUp Key = iota
	KeyDown
	KeyEnter
	KeyEscape
	KeyCtrlC
	KeyCtrlD
	KeyCtrlU
	KeyQ
	KeyJ
	KeyK
	KeyG
	KeyShiftG
	KeyA
	KeyShiftA
	KeyPageUp
	KeyPageDown
	KeyMouseScrollUp
	KeyMouseScrollDown
	KeySpace
	KeyOther
)

type KeyInput added in v0.3.8

type KeyInput struct {
	Data []byte
	Err  error
}

KeyInput holds keyboard input data for channel communication

type LineType added in v0.3.4

type LineType int

LineType categorizes diff lines

const (
	LineContext LineType = iota
	LineAddition
	LineDeletion
	LineHeader
)

type MergeConflictResult added in v0.3.5

type MergeConflictResult struct {
	HasConflicts     bool
	ConflictingFiles []string
	TreeOID          string
}

MergeConflictResult represents the result of a merge conflict check

type MultiSelectItem

type MultiSelectItem struct {
	Label    string
	Value    string
	Selected bool
}

MultiSelectItem represents an item in a multi-select list

type Option

type Option struct {
	Option      string `yaml:"option"`                // Required: the key to press
	Description string `yaml:"description,omitempty"` // Optional: help text
	Script      string `yaml:"script,omitempty"`      // Optional: script for this option
	Default     bool   `yaml:"default,omitempty"`     // Optional: mark as default option
}

Option represents a selectable option with optional description and script

type Session

type Session struct {
	Branch     string
	Created    time.Time
	BaseBranch string
	Task       string
}

Session represents worktree session information

type UntrackedFile added in v0.3.5

type UntrackedFile struct {
	Path    string
	Content []byte
}

UntrackedFile represents an untracked file with its content

type ViewAction added in v0.3.4

type ViewAction int

ViewAction represents what the view should do

const (
	ViewActionNone ViewAction = iota
	ViewActionRedraw
	ViewActionSelect
	ViewActionClose
	ViewActionQuit
	ViewActionRefresh // Refresh file list after stage/unstage
)

type WIPChanges added in v0.3.5

type WIPChanges struct {
	WorktreePath string
	Branch       string
	Diff         string          // Combined staged+unstaged diff
	Untracked    []UntrackedFile // Untracked files with content
	HasChanges   bool
}

WIPChanges represents uncommitted changes from a worktree

type WorktreeChanges added in v0.3.5

type WorktreeChanges struct {
	Staged    int
	Unstaged  int
	Untracked int
}

WorktreeChanges holds counts of different change types

type WorktreeInfo

type WorktreeInfo struct {
	Path     string
	Branch   string
	Head     string
	Detached bool
}

WorktreeInfo represents information about a git worktree

type WorktreeStatus

type WorktreeStatus struct {
	Modified  int
	Untracked int
	Staged    int
}

WorktreeStatus represents the status of a worktree

Jump to

Keyboard shortcuts

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