resolve

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package resolve provides target resolution for worktree commands.

Many wt commands operate on a specific worktree identified by its numeric ID. This package handles looking up worktrees from the cache and validating they still exist on disk.

ID-Based Resolution

Use ByID to resolve a worktree target:

target, err := resolve.ByID(5, scanDir)
if err != nil {
    // ID not found, worktree removed, or path doesn't exist
}
// target.Path, target.Branch, target.MainRepo available

Error Cases

ByID returns descriptive errors for:

  • ID not found in cache
  • Worktree was marked as removed
  • Path no longer exists on disk
  • Cannot determine main repo path

Usage Pattern

Commands that use ID resolution follow this pattern:

  • Required ID: wt exec -i 5, wt cd -i 3
  • Optional ID: wt note (defaults to current worktree), wt pr create

The -i/--id flag is used consistently across commands for worktree targeting. Commands may also support -r/--repository and -l/--label for repo-based targeting, but those are handled separately in the command implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Target

type Target struct {
	ID       int
	Branch   string
	MainRepo string
	Path     string
}

Target represents a resolved worktree target

func ByID

func ByID(id int, scanDir string) (*Target, error)

ByID resolves a worktree target by its numeric ID only. Returns error if ID not found, worktree was removed, or path no longer exists.

Jump to

Keyboard shortcuts

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