state

package
v0.0.0-...-ad7ab41 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RepoName

type RepoName struct {
	VCS, Repo string
}

func NewRepoName

func NewRepoName(repo api.Repository) RepoName

func (RepoName) LogValue

func (n RepoName) LogValue() slog.Value

type State

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

func New

func (*State) MaybeFindRepository

func (st *State) MaybeFindRepository(ctx context.Context, workUnitName string) (api.Repository, error)

MaybeFindRepository attempts to find an api.Repository that's currently active in tmux and claims that the given work unit exists. Returns an error if multiple api.Repositories claim that the given work unit exists. Returns nil, nil if no such api.Repository exists.

func (*State) NewSession

func (st *State) NewSession(ctx context.Context, repo api.Repository, workUnitName string) (tmux.Session, error)

NewSession creates a tmux session for the given work unit. Returns an error if the session already exists.

func (*State) PruneSessions

func (st *State) PruneSessions(ctx context.Context) error

func (*State) RenameSession

func (st *State) RenameSession(ctx context.Context, repo api.Repository, old, new string) error

RenameSession finds a tmux session for work unit old and then renames that session so that it represents work unit new. Returns an error if the "old" tmux session doesn't exist or if there's already a "new" tmux session.

func (*State) Repositories

func (st *State) Repositories() map[RepoName]api.Repository

Repositories returns a representative example for each known RepoName.

func (*State) Session

func (st *State) Session(repo api.Repository, workUnitName string) tmux.Session

Session determines if a tmux session for the given work unit exists.

func (*State) SessionName

func (st *State) SessionName(n WorkUnitName) string

SessionName returns the string that this State would use for the tmux session name if a work unit with the given name were created right now.

func (*State) Sessions

func (st *State) Sessions() map[WorkUnitName]tmux.Session

Sessions returns all tmux sessions keyed by their work unit.

func (*State) UnknownSessions

func (st *State) UnknownSessions() map[string]tmux.Session

UnknownSessions returns all tmux sessions that didn't appear to have a work unit.

func (*State) WorkUnit

func (st *State) WorkUnit(ctx context.Context, sesh tmux.Session) (api.Repository, string, error)

WorkUnit returns work unit metadata for the given session.

type WorkUnitName

type WorkUnitName struct {
	RepoName
	WorkUnit string
}

func NewWorkUnitName

func NewWorkUnitName(repo api.Repository, workUnitName string) WorkUnitName

func ParseSessionName

func ParseSessionName(repo api.Repository, tmuxSessionName string) WorkUnitName

func (WorkUnitName) LogValue

func (n WorkUnitName) LogValue() slog.Value

func (WorkUnitName) RepoString

func (n WorkUnitName) RepoString() string

func (WorkUnitName) WorkUnitString

func (n WorkUnitName) WorkUnitString() string

Jump to

Keyboard shortcuts

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