app

package
v0.0.0-...-1f1f7aa Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtrlR = "ctrl+r"
	CtrlS = "ctrl+s"
	CtrlC = "ctrl+c"
	Enter = "enter"
)

Keys

Variables

View Source
var (
	ErrCancelled = errors.New("cancelled")
)

App errors

Functions

func GetCWD

func GetCWD() string

func GetSubtreePath

func GetSubtreePath() string

func InitList

func InitList(items []list.Item, delegate ItemDelegate) list.Model

Types

type App

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

func InitApp

func InitApp(state AppState) App

func (App) GetWorktrees

func (a App) GetWorktrees() ([]Worktree, error)

GetWorktrees returns the worktree list for the repo of which cwd is part of

func (App) NewModel

func (a App) NewModel() (Model, error)

func (App) ParseCommandOutput

func (a App) ParseCommandOutput(buf bytes.Buffer) []Worktree

ParseCommandOutput parses the "git worktree list --porcelain" command output and returns a list of Worktree

func (App) Run

func (a App) Run() error

type AppState

type AppState struct {
	ShowRelativePath     bool
	SwitchToWorktreeRoot bool
	CurrentIndex         int
}

type ItemDelegate

type ItemDelegate struct{}

func (ItemDelegate) Height

func (ItemDelegate) Height() int

Height implements list.ItemDelegate

func (ItemDelegate) Render

func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, item list.Item)

Render implements list.ItemDelegate

func (ItemDelegate) Spacing

func (ItemDelegate) Spacing() int

Spacing implements list.ItemDelegate

func (ItemDelegate) Update

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

Update implements list.ItemDelegate

type Model

type Model struct {
	// Selected worktree
	Selected Worktree

	// App state
	AppState *AppState

	// List of worktrees
	WorktreeList list.Model
}

func (Model) Init

func (Model) Init() tea.Cmd

Init implements tea.Model

func (Model) Update

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

Update implements tea.Model

func (Model) View

func (m Model) View() string

View implements tea.Model

type Worktree

type Worktree struct {
	// Absolute path of the git worktree directory
	RootPath string
	// Relative path of RootPath with respect
	// to the current working directory
	RootPathRelative string
	// Absolute path of the directory which can be reached
	// from appending the path of current directory relative
	// to the top-level directory to the RootPath. This path
	// may or may not exist.
	// Eg.
	//	CWD = $BRANCH-1/a/b/c
	//	Here,
	//		subtree is a/b/c
	//		ValidSubtreePath would be <current_worktree_root>/a/b/c
	//			if it exist
	ValidSubtreePath string
	// Relative path of ValidSubtreePath with respect
	// to the current working directory
	ValidSubtreePathRelative string
	// Worktree branch
	Branch string
	// Head
	Head string
	// Reason for lock
	Reason string
	// Whether the worktree is locked
	Locked bool
	// Whether the head is detached
	Detached bool
	// Whether the worktree can be pruned
	Prunable bool
	// Whether the repo is a bare repo
	Bare bool
	// contains filtered or unexported fields
}

Worktree defines a git worktree

func (Worktree) Dir

func (w Worktree) Dir() string

func (*Worktree) Enrich

func (w *Worktree) Enrich(app App)

func (Worktree) FilterValue

func (w Worktree) FilterValue() string

Jump to

Keyboard shortcuts

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