Skip to main content

Module cli

Module cli 

Source

Structs§

Cli
RepoContext
The repo prelude shared by most CLI subcommands: an open Repository, its working directory, and the resolved Config. Owned values so call sites keep borrowing &repo, &workdir, &config exactly as they did when the triplet was inlined.

Enums§

AliasesAction
Subcommands of gwm aliases (issue #86). Read-only for now — declarative editing of the alias set stays in TOML files where users can grep / diff / version-control them. A future add / remove could land if real usage justifies it.
Command
ConfigAction
Subcommands of gwm config (issue #89).
HookKind
Discriminator for gwm hooks install <kind>. A ValueEnum (rather than a free-form string) so clap rejects typos at parse time (gwm hooks install commit-msge → “invalid value … expected one of: commit-msg”) rather than letting the installer fail with a less-actionable error.
HooksAction
Subcommands of gwm hooks (issue #85). The split anticipates future hook variants (pre-push, pre-commit); for now only install commit-msg is wired up, which is the directly-load-bearing surface for the auto-prefix workflow.
InitShell
LabelsAction
Subcommands of gwm labels. The split is intentional: list is read-only and safe to run in CI; push mutates the remote and therefore gets --dry-run / --prune flags of its own.
LinkTarget
Target of gwm link / unlink / open — issue or pull request.
ListFormat
MilestonesAction
Subcommands of gwm milestones. Mirrors LabelsAction: list is read-only and safe to run in CI; push mutates the remote and therefore gets --dry-run / --prune flags of its own.
OutputFormat
Output format for commands that have only a human-readable text form and a machine-readable JSON form (gwm path, gwm doctor — issue #38). Distinct from ListFormat, which also carries the names variant.
ThemeAction
Subcommands of gwm theme (issue #33).
TrustAction
Subcommands of gwm trust (issue #95). All three are read-only or purely local — no network, no git mutation — so they’re safe to surface in CI as inspection helpers.
TuiAction
Subcommands of gwm tui (issue #87).

Functions§

build_status_json
Build the gwm status --json payload — a stable, hand-built schema for scripting (frozen by tests/contract_tests.rs, documented in docs/schema/status.schema.json, issue #317). Pure: returns the value so the contract test can pin its shape without spawning the binary or hitting GitHub. print-ing is the caller’s job.
format_history_row
Render one journal entry as a single line for gwm history. Shape: <ago> <kind> <worktree> [(undone)]. Extracted as a pure function so the formatter is unit-testable without spinning up a real journal (see cli_format_tests.rs).
format_prune_plan
Render the would-do plan for gwm prune --dry-run (issue #31). Extracted from cmd_prune so the formatter is unit-testable on arbitrary PrunableEntry fixtures (non-ASCII names / paths without needing a real repo). Pure function: trailing newline included; empty input still emits the canonical “0 worktree(s) to prune” line so piped consumers get a stable signal instead of empty stdout.
format_remove_plan
Render the would-do plan for gwm remove --dry-run (issue #31). Extracted from cmd_remove so the formatter is unit-testable without spinning up a real worktree. Pure function: takes the resolved name + path + branch, returns a multi-line string (trailing newline included).
format_sync_report
Render a successful SyncReport as a single ✓ status line. The error paths (dirty tree, missing upstream, conflicts) surface as GwmError and are printed by main’s top-level handler, so this only ever formats the success cases.
repo_context
Discover the repo, resolve its workdir, and load .gwm.toml.
repo_context_lenient
Like repo_context, but tolerates a missing or malformed .gwm.toml by falling back to Config::default. The repo and workdir gates stay strict — only the config load is lenient. Used by gwm doctor, which must run even when the config it is about to diagnose is broken.
run
shell_init_script