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

cmd

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cmd defines all cobra commands for git-iter.

Index

Constants

View Source
const (
	DefaultTextDesc     = "Stream stdout/stderr of each process directly (default)."
	DefaultJSONDesc     = "Emit one JSON object per repository (JSON Lines):"
	DefaultMarkdownDesc = "Emit a formatted Markdown document with summaries (or md)."

	JSONRowRepoAbsPath = "repo_abs_path"
	JSONRowRepoRelPath = "repo_rel_path"
	JSONRowCommand     = "command"
	JSONRowExitCode    = "exit_code"
	JSONRowStdout      = "stdout"
	JSONRowStderr      = "stderr"

	JSONRowRepoAbsPathDesc = "absolute path of the repository"
	JSONRowRepoRelPathDesc = "path relative to --repos-root"
	JSONRowStderrDesc      = "captured standard error"

	ExampleDescJSONLines = "Collect results as JSON Lines"
)

Common output mode description constants.

Variables

View Source
var (
	ParseDoArgs              = parse.ParseDoArgs
	ParseDoArgsWithDash      = parse.ParseDoArgsWithDash
	ParseGrepArgs            = parse.ParseGrepArgs
	ParseGrepArgsWithDash    = parse.ParseGrepArgsWithDash
	ParseListArgs            = parse.ParseListArgs
	ParseReadArgs            = parse.ParseReadArgs
	ParsePullArgs            = parse.ParsePullArgs
	ParsePullArgsWithDash    = parse.ParsePullArgsWithDash
	ParseFetchArgs           = parse.ParseFetchArgs
	ParseFetchArgsWithDash   = parse.ParseFetchArgsWithDash
	ParseLsFilesArgs         = parse.ParseLsFilesArgs
	ParseLsFilesArgsWithDash = parse.ParseLsFilesArgsWithDash
	ParseStatusArgs          = parse.ParseStatusArgs
	ParseStatusArgsWithDash  = parse.ParseStatusArgsWithDash
	ParseDiffArgs            = parse.ParseDiffArgs
	ParseDiffArgsWithDash    = parse.ParseDiffArgsWithDash
	ParseGetArgs             = parse.ParseGetArgs
	ParseWorktreeListArgs    = parse.ParseWorktreeListArgs
	ParseWorktreeAddArgs     = parse.ParseWorktreeAddArgs
	ParseWorktreeRemoveArgs  = parse.ParseWorktreeRemoveArgs
	ParseWorktreePruneArgs   = parse.ParseWorktreePruneArgs
)
View Source
var (
	RunDo             = cmdRunner.RunDo
	RunRead           = cmdRunner.RunRead
	RunList           = cmdRunner.RunList
	RunGrep           = cmdRunner.RunGrep
	RunPull           = cmdRunner.RunPull
	RunFetch          = cmdRunner.RunFetch
	RunLsFiles        = cmdRunner.RunLsFiles
	RunStatus         = cmdRunner.RunStatus
	RunDiff           = cmdRunner.RunDiff
	RunGet            = cmdRunner.RunGet
	RunWorktreeList   = cmdRunner.RunWorktreeList
	RunWorktreeAdd    = cmdRunner.RunWorktreeAdd
	RunWorktreeRemove = cmdRunner.RunWorktreeRemove
	RunWorktreePrune  = cmdRunner.RunWorktreePrune
)

Aliases for runner functions moved to internal/cmd/runner.

View Source
var ErrConflictingBranchFlags = fmt.Errorf("cannot specify both --default-branch-only and --not-default-branch-only")

ErrConflictingBranchFlags is returned when both --default-branch-only and --not-default-branch-only are set.

View Source
var ErrConflictingFilterFlags = fmt.Errorf("cannot specify both --dirty-only (-d) and --clean-only (-c)")

ErrConflictingFilterFlags is returned when both --dirty-only and --clean-only are set.

View Source
var ErrNoRepoSource = errors.New("either --repos-root (-r) or --list-repos must be set")

ErrNoRepoSource is returned when neither --repos-root nor --list-repos is configured.

Functions

func ConfigFromContext

func ConfigFromContext(ctx context.Context) *config.Config

ConfigFromContext retrieves the Config stored in ctx by NewRootCmd's PersistentPreRunE.

func FormatItems

func FormatItems(items []Item, indent, spacing int) string

FormatItems aligns items into a 2-column list with indent and spacing.

func NewDiffCmd

func NewDiffCmd() *cobra.Command

NewDiffCmd returns the "diff" sub-command.

func NewDoCmd

func NewDoCmd() *cobra.Command

NewDoCmd returns the "do" sub-command.

func NewFetchCmd

func NewFetchCmd() *cobra.Command

NewFetchCmd returns the "fetch" sub-command.

func NewGetCmd added in v0.3.0

func NewGetCmd() *cobra.Command

NewGetCmd returns the "get" sub-command.

func NewGrepCmd

func NewGrepCmd() *cobra.Command

NewGrepCmd returns the "grep" sub-command.

func NewListCmd

func NewListCmd() *cobra.Command

NewListCmd returns the "list" (alias: "ls") sub-command.

func NewLsFilesCmd

func NewLsFilesCmd() *cobra.Command

NewLsFilesCmd returns the "ls-files" (alias: "lsf") sub-command.

func NewMcpCmd

func NewMcpCmd() *cobra.Command

NewMcpCmd returns the "mcp" sub-command.

func NewPullCmd

func NewPullCmd() *cobra.Command

NewPullCmd returns the "pull" sub-command.

func NewReadCmd

func NewReadCmd() *cobra.Command

NewReadCmd returns the "read" sub-command.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd constructs the root cobra command with all sub-commands registered. Each call creates a fresh pflag.FlagSet so that tests can create multiple independent command trees without flag-redefinition panics.

func NewStatusCmd

func NewStatusCmd() *cobra.Command

NewStatusCmd returns the "status" (alias: "st") sub-command.

func NewVersionCmd

func NewVersionCmd() *cobra.Command

func NewWorktreeAddCmd added in v0.4.0

func NewWorktreeAddCmd() *cobra.Command

NewWorktreeAddCmd returns the "worktree add" (alias: "a") sub-command.

func NewWorktreeCmd added in v0.4.0

func NewWorktreeCmd() *cobra.Command

NewWorktreeCmd returns the "worktree" (alias: "wt") parent sub-command.

func NewWorktreeListCmd added in v0.4.0

func NewWorktreeListCmd() *cobra.Command

NewWorktreeListCmd returns the "worktree list" (aliases: "ls", "l") sub-command.

func NewWorktreePruneCmd added in v0.4.0

func NewWorktreePruneCmd() *cobra.Command

NewWorktreePruneCmd returns the "worktree prune" (alias: "p") sub-command.

func NewWorktreeRemoveCmd added in v0.4.0

func NewWorktreeRemoveCmd() *cobra.Command

NewWorktreeRemoveCmd returns the "worktree remove" (aliases: "r", "rm") sub-command.

func OutModeFromContext

func OutModeFromContext(ctx context.Context) string

OutModeFromContext retrieves the output mode ("text" or "json") from ctx. Returns "text" when not set.

Types

type DiffArgs

type DiffArgs = parse.DiffArgs

Aliases for types and functions moved to internal/cmd/parse.

type DoArgs

type DoArgs = parse.DoArgs

Aliases for types and functions moved to internal/cmd/parse.

type Example

type Example struct {
	Desc    string // Description of what the example does (e.g. "Run git status in all repositories")
	Command string // The shell command invocation (e.g. "git-iter -r /repos do -- git status")
}

Example represents a usage example consisting of a description and a command.

func (Example) Format

func (e Example) Format() string

Format formats the example as a comment description followed by the command.

type FetchArgs

type FetchArgs = parse.FetchArgs

Aliases for types and functions moved to internal/cmd/parse.

type GetArgs added in v0.3.0

type GetArgs = parse.GetArgs

Aliases for types and functions moved to internal/cmd/parse.

type GrepArgs

type GrepArgs = parse.GrepArgs

Aliases for types and functions moved to internal/cmd/parse.

type Item

type Item struct {
	Term string // Term or name (e.g. "-d, --dirty-only", "repo_abs_path")
	Desc string // Description of the item
}

Item represents a term and its description (e.g. flag or field).

type ListArgs

type ListArgs = parse.ListArgs

Aliases for types and functions moved to internal/cmd/parse.

type LongDoc

type LongDoc struct {
	// Header is the opening synopsis or description of what the subcommand does.
	Header string
	// RepoFilter indicates whether to include the standard REPO_REGEX filter explanation.
	RepoFilter bool
	// DashSeparation explains how arguments before and after "--" are separated (if applicable).
	DashSeparation string
	// Sections contains additional structured sections (flags, options, notes) rendered with Title/Body/Items.
	Sections []Section
	// ExecutionNote indicates whether to include standard notes about working directory and parallelism controls.
	ExecutionNote bool
	// OutputModes specifies the explanations for text, json, and markdown output formats.
	OutputModes OutputModeDoc
	// Examples contains command usage examples appended at the end of help text.
	Examples []Example
}

LongDoc defines the structured sections of a subcommand's Long help text. Build() concatenates these sections in order with standardized formatting.

func (LongDoc) Build

func (d LongDoc) Build() string

Build constructs the formatted Long documentation string.

type LsFilesArgs

type LsFilesArgs = parse.LsFilesArgs

Aliases for types and functions moved to internal/cmd/parse.

type OutputModeDoc

type OutputModeDoc struct {
	Text     string // Description for text mode
	JSON     string // Description for json mode
	JSONRows []Item // Field descriptions for json mode
	Markdown string // Description for markdown/md mode
}

OutputModeDoc describes the output modes supported by a subcommand.

func DefaultOutputModeDoc

func DefaultOutputModeDoc() OutputModeDoc

DefaultOutputModeDoc returns the standard output mode documentation for process-executing commands.

func RepoListOutputModeDoc added in v0.3.0

func RepoListOutputModeDoc() OutputModeDoc

RepoListOutputModeDoc returns the standard output mode documentation for repository-listing commands.

type PullArgs

type PullArgs = parse.PullArgs

Aliases for types and functions moved to internal/cmd/parse.

type ReadArgs

type ReadArgs = parse.ReadArgs

Aliases for types and functions moved to internal/cmd/parse.

type Section

type Section struct {
	Title string // Section title (e.g. "Flags:", "Filter flags (global):")
	Body  string // Free-form body text (optional)
	Items []Item // Structured key-value items with automatic alignment (optional)
}

Section represents a structured section in help documentation.

func (Section) Format

func (s Section) Format() string

Format renders the section to a formatted string.

type StatusArgs

type StatusArgs = parse.StatusArgs

Aliases for types and functions moved to internal/cmd/parse.

type WorktreeAddArgs added in v0.4.0

type WorktreeAddArgs = parse.WorktreeAddArgs

Aliases for types and functions moved to internal/cmd/parse.

type WorktreeListArgs added in v0.4.0

type WorktreeListArgs = parse.WorktreeListArgs

Aliases for types and functions moved to internal/cmd/parse.

type WorktreePruneArgs added in v0.4.0

type WorktreePruneArgs = parse.WorktreePruneArgs

Aliases for types and functions moved to internal/cmd/parse.

type WorktreeRemoveArgs added in v0.4.0

type WorktreeRemoveArgs = parse.WorktreeRemoveArgs

Aliases for types and functions moved to internal/cmd/parse.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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