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

cmd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 20 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
)
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
)

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

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 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 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 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.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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