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

cmd

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommand

func AddCommand(runner git.Runner) *cli.Command

AddCommand returns the `wtg add` command.

func ArchiveCommand added in v1.6.0

func ArchiveCommand(runner git.Runner) *cli.Command

ArchiveCommand returns the `wtg repo archive` subcommand.

func ConfigCommand

func ConfigCommand() *cli.Command

ConfigCommand returns the `wtg config` command group. With no subcommand it prints the resolved config file's raw contents.

func DeleteCommand

func DeleteCommand(runner git.Runner) *cli.Command

DeleteCommand returns the `wtg delete` command.

func ExecCommand

func ExecCommand() *cli.Command

ExecCommand returns the `wtg exec` command.

func NewCommand

func NewCommand(runner git.Runner) *cli.Command

NewCommand returns the `wtg new` command.

func PathCommand

func PathCommand() *cli.Command

PathCommand returns the `wtg path` command (hidden; used by shell wcd functions).

func PushCommand

func PushCommand(runner git.Runner) *cli.Command

PushCommand returns the `wtg push` command.

func RebaseCommand added in v1.7.0

func RebaseCommand(runner git.Runner) *cli.Command

RebaseCommand returns the `wtg rebase` command.

func RemoveCommand

func RemoveCommand(runner git.Runner) *cli.Command

RemoveCommand returns the `wtg remove` command.

func RepoCommand

func RepoCommand(runner git.Runner) *cli.Command

RepoCommand returns the `wtg repo` command with its subcommands.

func RunFetch

func RunFetch(cfg *config.Config, runner git.Runner, args []string, out io.Writer) error

RunFetch fetches from origin for each repo without fast-forwarding. If args is empty, all discovered repos are fetched. Otherwise args are short names (relative to a discovery root dir) to fetch.

func RunRepoArchive added in v1.6.0

func RunRepoArchive(cfg *config.Config, runner git.Runner, args RepoArchiveArgs, out io.Writer) error

RunRepoArchive moves one or more main repo clones into archive.root_dir and records their provenance. It never deletes anything. Pending work (uncommitted files, commits not on any remote, stashes) aborts the run unless args.Force is set; a clone that is in use (live or stale worktrees, referenced by a space, or listed in always.repos) aborts the run unconditionally.

With args.Remote, each repo is also archived upstream on GitHub via gh, after an auth pre-flight and as part of the same saga, so a failure rolls the local moves back. See docs/adr/0013-repo-archive.md.

func RunRepoStatus

func RunRepoStatus(cfg *config.Config, runner git.Runner, args []string, long bool, out io.Writer) error

RunRepoStatus prints a status table for all discovered repos (or the named subset). Each row shows the repo name, current branch, working-tree state, and ahead/behind counts relative to origin. When long is true, the remote URL and absolute path are appended in a muted style.

func RunRepoUnarchive added in v1.6.0

func RunRepoUnarchive(cfg *config.Config, args RepoUnarchiveArgs, out io.Writer) error

RunRepoUnarchive restores one or more archived repo clones to the exact paths recorded when they were archived, and removes their provenance records. It never deletes anything. With args.Remote each repo is also unarchived upstream on GitHub, after an auth pre-flight and as part of the same saga, so a failure rolls the local restores back. See docs/adr/0013-repo-archive.md.

func RunSpaceAdd

func RunSpaceAdd(cfg *config.Config, runner git.Runner, args SpaceAddArgs, out io.Writer) error

RunSpaceAdd adds one or more repos to a workspace by creating worktrees on the space's branch and updating the go.work file and state. If a requested repo is currently a symlink in the space (added via always.repos), the symlink is replaced with a proper worktree on the space's branch.

func RunSpaceDelete

func RunSpaceDelete(cfg *config.Config, runner git.Runner, args SpaceDeleteArgs, in io.Reader, out io.Writer) error

RunSpaceDelete removes all worktrees belonging to a space. If -d or -D is set, branches are also deleted. Prompts the user when uncommitted changes or unpushed commits are detected; only deletes state once all removals succeed.

func RunSpaceExec

func RunSpaceExec(spaceName string, args []string, parallel bool, out io.Writer) error

RunSpaceExec runs a command in each worktree of the named space. When parallel is false it runs sequentially, streaming output as it goes. When parallel is true all commands run concurrently; a progress indicator (matching the sync --progress style) shows live status, and each repo's complete buffered output is printed serially in repo order once all commands have finished. In both modes execution continues past failures and all failed repos are reported at the end.

func RunSpaceNew

func RunSpaceNew(cfg *config.Config, runner git.Runner, args SpaceNewArgs, out io.Writer) error

RunSpaceNew creates a new workspace, checking out a worktree in each selected repo and writing a go.work file if any repos are Go modules. Repos listed in cfg.Always.Repos are symlinked into the space unless they are also explicitly named in args.Repos (in which case they get a worktree). Files listed in cfg.Always.Files are copied into the space root. Paths in cfg.Always.Secrets are copied from each source repo into its worktree when present.

func RunSpacePush

func RunSpacePush(runner git.Runner, spaceName string, out io.Writer) error

RunSpacePush pushes each repo's branch to origin in parallel.

func RunSpaceRebase added in v1.7.0

func RunSpaceRebase(runner git.Runner, spaceName, onto string, progress bool, out io.Writer) error

RunSpaceRebase fetches origin and rebases each repo's workspace branch onto its base branch in parallel. See docs/adr/0018-workspace-rebase.md.

func RunSpaceRemove

func RunSpaceRemove(cfg *config.Config, runner git.Runner, args SpaceRemoveArgs, in io.Reader, out io.Writer) error

RunSpaceRemove removes one or more repos from a workspace by deleting their worktrees and updating the go.work file and state. It mirrors the safety checks of RunSpaceDelete: uncommitted changes and unpushed commits prompt for confirmation before proceeding.

Special handling for always.repos entries: if the removed repo is in cfg.Always.Repos and was a real worktree (not already a symlink), a symlink is restored in its place rather than leaving the repo absent from the space. Removing a repo that is currently a symlink leaves it absent (the user explicitly opted out for this space).

func RunSpaceStatus

func RunSpaceStatus(runner git.Runner, names []string, detailed bool, out io.Writer) error

RunSpaceStatus shows workspace status. With no arguments it prints per-repo detail for every space; the space containing the current directory is shown first. With named spaces it shows full per-repo detail for each. The --detailed flag adds individual modified-file listings under each repo row.

func RunSync

func RunSync(cfg *config.Config, runner git.Runner, args []string, progress bool, out io.Writer) error

RunSync fetches and fast-forwards each repo's default branch. If args is empty, all discovered repos are synced. Otherwise, args are short names (relative to a discovery root dir) to sync. When progress is true, a bracketed row of placeholder dots is printed upfront — one per repo — and each dot is replaced in-place with the result symbol (✓ ↑ ⚠ !) as soon as that repo finishes, by reprinting the whole line from column 0 with \r.

func StatusCommand

func StatusCommand(runner git.Runner) *cli.Command

StatusCommand returns the top-level `wtg status` command.

func UnarchiveCommand added in v1.6.0

func UnarchiveCommand() *cli.Command

UnarchiveCommand returns the `wtg repo unarchive` subcommand.

Types

type RepoArchiveArgs added in v1.6.0

type RepoArchiveArgs struct {
	Repos      []string // repo names to archive (at least one)
	Force      bool     // proceed despite pending work
	DryRun     bool     // report the plan without moving anything
	ArchiveDir string   // overrides cfg.Archive.RootDir when non-empty
	Remote     bool     // also archive each repo upstream on GitHub via gh

	// GH is the gh client used when Remote is set. It is nil in normal use (the
	// system gh CLI is used); tests inject a fake here.
	GH remote.Runner
}

RepoArchiveArgs holds the parsed arguments for RunRepoArchive.

type RepoUnarchiveArgs added in v1.6.0

type RepoUnarchiveArgs struct {
	Repos      []string // archived repo names to restore (at least one)
	DryRun     bool     // report the plan without moving anything
	Remote     bool     // also unarchive each repo upstream on GitHub via gh
	ArchiveDir string   // overrides cfg.Archive.RootDir when non-empty

	// GH is the gh client used when Remote is set. It is nil in normal use (the
	// system gh CLI is used); tests inject a fake here.
	GH remote.Runner
}

RepoUnarchiveArgs holds the parsed arguments for RunRepoUnarchive.

type SpaceAddArgs

type SpaceAddArgs struct {
	Name  string
	Repos []string // short names of repos to add (required)
}

SpaceAddArgs holds the parsed arguments for RunSpaceAdd.

type SpaceDeleteArgs

type SpaceDeleteArgs struct {
	Name         string
	DeleteBranch bool // -d: delete branch if fully merged
	ForceBranch  bool // -D: force-delete branch regardless of merge state
}

SpaceDeleteArgs holds the parsed arguments for RunSpaceDelete.

type SpaceNewArgs

type SpaceNewArgs struct {
	Name   string
	Branch string   // overrides cfg.Git.BranchPrefix+Name when set
	Path   string   // overrides cfg.Spaces.RootDir/Name when set
	Base   string   // commit-ish to branch from (default: HEAD)
	Repos  []string // short names; at least one required
}

SpaceNewArgs holds the parsed arguments for RunSpaceNew.

type SpaceRemoveArgs

type SpaceRemoveArgs struct {
	Name         string
	Repos        []string // short names of repos to remove (required)
	DeleteBranch bool     // -d: delete branch if fully merged
	ForceBranch  bool     // -D: force-delete branch regardless of merge state
}

SpaceRemoveArgs holds the parsed arguments for RunSpaceRemove.

Jump to

Keyboard shortcuts

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