Help us shape the future of Go! Take the 2026 Go Developer Survey

navigation

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package navigation implements the stackit top/bottom commands for navigating stacked branches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenThroughAnchors added in v0.27.0

func FlattenThroughAnchors(branches engine.Branches, graph *engine.StackGraph) engine.Branches

FlattenThroughAnchors replaces worktree anchor branches with their non-anchor children.

func SwitchBranchAction

func SwitchBranchAction(ctx context.Context, deps Deps, direction Direction, handler Handler) (checkout.Result, error)

SwitchBranchAction switches to a branch based on the given direction

Types

type Deps added in v0.30.1

type Deps struct {
	Engine Engine
	Out    output.Output
	// Log, Quiet and Here pass through to the checkout of the target branch.
	Log   output.Logger
	Quiet bool
	Here  actions.Here
}

Deps are the collaborators navigation needs. Adapters build them from their own runtime state; the action never sees bootstrap types.

type Direction

type Direction string

Direction represents the traversal direction

const (
	// DirectionBottom specifies navigating towards the trunk
	DirectionBottom Direction = "BOTTOM"
	// DirectionTop specifies navigating towards the stack tips
	DirectionTop Direction = "TOP"
)

type Engine added in v0.30.1

type Engine interface {
	checkout.Engine
}

Engine lists exactly the engine methods navigation calls, including those of the checkout it finishes with.

type Handler

type Handler interface {
	// PromptSelectBranch prompts user to select a branch when multiple children exist
	// Returns the selected branch name
	PromptSelectBranch(message string, branches []string) (string, error)

	// Cleanup restores terminal state (may be no-op)
	Cleanup()

	// IsInteractive returns true if the handler supports interactive prompts
	IsInteractive() bool
}

Handler receives events from navigation action

type NullHandler

type NullHandler struct {
	handler.NullBase
}

NullHandler is a no-op handler for when nil is passed. It embeds handler.NullBase for Cleanup() and IsInteractive().

func (*NullHandler) PromptSelectBranch

func (h *NullHandler) PromptSelectBranch(string, []string) (string, error)

PromptSelectBranch implements Handler. Returns empty string for null handler.

Jump to

Keyboard shortcuts

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