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

parse

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: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitWithDash

func SplitWithDash(args []string, dashIndex int) (patterns, command []string)

SplitWithDash splits args into patterns (before dash) and command/flags (after dash). If dashIndex >= 0 (provided by Cobra ArgsLenAtDash), it splits at that index. Otherwise, it falls back to looking for a literal "--" element in args.

Types

type DiffArgs

type DiffArgs struct {
	Patterns    []string // repository filter regexps; empty means all
	DiffFlags   []string // optional arguments forwarded to "git diff"
	Interactive bool     // whether to run git diff interactively (with pager)
}

DiffArgs is the parsed argument set for the "diff" subcommand.

func ParseDiffArgs

func ParseDiffArgs(args []string) DiffArgs

ParseDiffArgs parses raw cobra args into DiffArgs.

func ParseDiffArgsWithDash

func ParseDiffArgsWithDash(args []string, dashIndex int) DiffArgs

ParseDiffArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type DoArgs

type DoArgs struct {
	Patterns []string // repository filter regexps
	Command  []string // command to run in each matching repo
}

DoArgs is the parsed argument set for the "do" subcommand.

func ParseDoArgs

func ParseDoArgs(args []string) (DoArgs, error)

ParseDoArgs parses raw cobra args into DoArgs. Returns an error when no COMMAND is provided after "--".

func ParseDoArgsWithDash

func ParseDoArgsWithDash(args []string, dashIndex int) (DoArgs, error)

ParseDoArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type FetchArgs

type FetchArgs struct {
	Patterns   []string // repository filter regexps; empty means all
	FetchFlags []string // optional arguments forwarded to "git fetch"
}

FetchArgs is the parsed argument set for the "fetch" subcommand.

func ParseFetchArgs

func ParseFetchArgs(args []string) FetchArgs

ParseFetchArgs parses raw cobra args into FetchArgs.

func ParseFetchArgsWithDash

func ParseFetchArgsWithDash(args []string, dashIndex int) FetchArgs

ParseFetchArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type GetArgs added in v0.3.0

type GetArgs struct {
	URI string // repository URI to clone/resolve; empty means list all repositories
}

GetArgs is the parsed argument set for the "get" subcommand.

func ParseGetArgs added in v0.3.0

func ParseGetArgs(args []string) GetArgs

ParseGetArgs parses raw cobra args into GetArgs.

type GrepArgs

type GrepArgs struct {
	Patterns    []string // repository filter regexps
	GitGrepArgs []string // arguments forwarded verbatim to "git grep"
}

GrepArgs is the parsed argument set for the "grep" subcommand.

func ParseGrepArgs

func ParseGrepArgs(args []string) (GrepArgs, error)

ParseGrepArgs parses raw cobra args into GrepArgs. Returns an error when no GIT_GREP_ARGS are provided after "--".

func ParseGrepArgsWithDash

func ParseGrepArgsWithDash(args []string, dashIndex int) (GrepArgs, error)

ParseGrepArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type ListArgs

type ListArgs struct {
	Patterns []string // repository filter regexps; empty means all
}

ListArgs is the parsed argument set for the "list" subcommand.

func ParseListArgs

func ParseListArgs(args []string) ListArgs

ParseListArgs parses raw cobra args into ListArgs. Never errors.

type LsFilesArgs

type LsFilesArgs struct {
	Patterns     []string // repository filter regexps; empty means all
	LsFilesFlags []string // optional arguments forwarded to "git ls-files"
}

LsFilesArgs is the parsed argument set for the "ls-files" subcommand.

func ParseLsFilesArgs

func ParseLsFilesArgs(args []string) LsFilesArgs

ParseLsFilesArgs parses raw cobra args into LsFilesArgs.

func ParseLsFilesArgsWithDash

func ParseLsFilesArgsWithDash(args []string, dashIndex int) LsFilesArgs

ParseLsFilesArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type PullArgs

type PullArgs struct {
	Patterns  []string // repository filter regexps; empty means all
	PullFlags []string // optional arguments forwarded to "git pull"
}

PullArgs is the parsed argument set for the "pull" subcommand.

func ParsePullArgs

func ParsePullArgs(args []string) PullArgs

ParsePullArgs parses raw cobra args into PullArgs.

func ParsePullArgsWithDash

func ParsePullArgsWithDash(args []string, dashIndex int) PullArgs

ParsePullArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type ReadArgs

type ReadArgs struct {
	Command []string // command to run in each repo read from stdin
}

ReadArgs is the parsed argument set for the "read" subcommand.

func ParseReadArgs

func ParseReadArgs(args []string) ReadArgs

ParseReadArgs parses raw cobra args into ReadArgs. Never errors; cobra MinimumNArgs(1) ensures args is non-empty before RunE is called.

type StatusArgs

type StatusArgs struct {
	Patterns    []string // repository filter regexps; empty means all
	StatusFlags []string // optional arguments forwarded to "git status"
}

StatusArgs is the parsed argument set for the "status" subcommand.

func ParseStatusArgs

func ParseStatusArgs(args []string) StatusArgs

ParseStatusArgs parses raw cobra args into StatusArgs.

func ParseStatusArgsWithDash

func ParseStatusArgsWithDash(args []string, dashIndex int) StatusArgs

ParseStatusArgsWithDash parses args taking into account Cobra's ArgsLenAtDash().

type WorktreeAddArgs added in v0.4.0

type WorktreeAddArgs struct {
	Branch    string // existing branch (when NewBranch is empty) or base branch (when NewBranch is set)
	NewBranch string // -b <new-branch>
}

WorktreeAddArgs is the parsed argument set for "worktree add".

func ParseWorktreeAddArgs added in v0.4.0

func ParseWorktreeAddArgs(args []string, newBranch string) (WorktreeAddArgs, error)

ParseWorktreeAddArgs parses raw cobra args and the -b flag into WorktreeAddArgs.

func (WorktreeAddArgs) TargetBranch added in v0.4.0

func (a WorktreeAddArgs) TargetBranch() string

TargetBranch returns the branch name that determines the worktree directory path.

type WorktreeListArgs added in v0.4.0

type WorktreeListArgs struct {
	Patterns []string // worktree path filter regexps; empty means all
	Repo     bool     // --repo: output unique main repository paths instead of worktree paths
	All      bool     // -a, --all: list across all repositories instead of current repository
	RepoDir  string   // target repo directory when All is false (defaults to cwd)
}

WorktreeListArgs is the parsed argument set for "worktree list".

func ParseWorktreeListArgs added in v0.4.0

func ParseWorktreeListArgs(args []string, repoOnly bool, all ...bool) WorktreeListArgs

ParseWorktreeListArgs parses raw cobra args and flags into WorktreeListArgs.

type WorktreePruneArgs added in v0.4.0

type WorktreePruneArgs struct {
	Patterns []string
	DryRun   bool
	All      bool
}

WorktreePruneArgs is the parsed argument set for "worktree prune".

func ParseWorktreePruneArgs added in v0.4.0

func ParseWorktreePruneArgs(args []string, dryRun, all bool) WorktreePruneArgs

ParseWorktreePruneArgs parses raw cobra args and flags into WorktreePruneArgs.

type WorktreeRemoveArgs added in v0.4.0

type WorktreeRemoveArgs struct {
	Branch            string
	Force             bool
	NoForce           bool
	DeleteBranch      bool
	ForceDeleteBranch bool
}

WorktreeRemoveArgs is the parsed argument set for "worktree remove".

func ParseWorktreeRemoveArgs added in v0.4.0

func ParseWorktreeRemoveArgs(args []string, force, noForce, deleteBranch, forceDeleteBranch bool) (WorktreeRemoveArgs, error)

ParseWorktreeRemoveArgs parses raw cobra args and flags into WorktreeRemoveArgs. If forceDeleteBranch is true, Force and DeleteBranch are also set to true.

Jump to

Keyboard shortcuts

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