Skip to main content

Crate wt

Crate wt 

Source
Expand description

wt — a Git worktree and GitHub PR manager (library crate).

All real logic lives here so it is unit-testable and counted by coverage; src/main.rs is a thin entry point. See spec.md for the full behavior specification.

The single entry point is run, which takes the command-line arguments and a Cx (injected I/O, environment, and working directory) and returns the process exit code. Keeping the side-effecting handles in Cx makes the whole dispatch path testable without touching the real terminal.

Re-exports§

pub use cx::Cx;
pub use cx::Env;
pub use cx::Stream;
pub use error::Error;
pub use error::Result;

Modules§

agent
The code-agent boundary (issue #11): detect installed agent CLIs and drive them in their JSON output mode. AgentClient isolates the subprocess work so callers can inject a fake; RealAgent spawns the real binaries. A missing binary yields Error::AgentUnavailable; a non-zero exit yields Error::Subprocess.
config
Configuration loading and merging (spec §11).
copy
Copying Git-ignored local files into newly created worktrees (spec §8).
cx
Runtime context: injected I/O, environment, and working directory.
error
Typed error type for the wt library.
gh
The GitHub boundary (spec §4): all pull-request operations shell out to the gh CLI. GhClient isolates this so tests can inject a fake; RealGh spawns the real binary. A missing or unauthenticated gh yields Error::GhUnavailable with an actionable message (§12).
git
The Git boundary (spec §4): gix for reads, the git CLI for mutations and network operations. Submodules:
hooks
Post-create and pre-remove hooks (spec §8). Hooks run via sh -c (Unix) or cmd /C (Windows) with the new worktree as the working directory and the WT_* variables in the environment.
keys
TUI key bindings (spec §10/§11): the action set, the default keymap, and parsing/rendering of key strings such as ctrl+u or f5.
model
Domain model: the worktree row and its JSON schema (spec §7), plus the sort and column enums used by list/status.
output
Output rendering: color decisions, paging, table layout, and the human renderers. Submodules are added as the command surface grows; the stdout/stderr discipline itself lives on crate::cx::Cx.
query
Query resolution (spec §7): match a query against a set of worktrees in a defined precedence order, reporting a unique match, ambiguity, or no match.
slug
Branch-slug normalization (spec §3).
template
Worktree-store path-template rendering (spec §6).
time
Time formatting for display (spec §7 “Display conventions”).
tui
The terminal UI (spec §10): a live dashboard and action center.
util
Shared utilities: fuzzy matching, filesystem helpers, and editor resolution.
version
Build and version metadata surfaced by wt --version / wt -V.

Functions§

run
Runs wt with the given command-line arguments (excluding argv[0]), writing through the provided Cx, and returns the process exit code.