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

cmd

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package cmd provides CLI commands for the gwq application.

Index

Constants

View Source
const (
	// EnvShellDepth is the environment variable name for tracking shell nesting depth.
	EnvShellDepth = "GWQ_SHELL_DEPTH"

	// DefaultNestWarningThreshold is the default depth at which to show a warning.
	DefaultNestWarningThreshold = 2
)

Variables

This section is empty.

Functions

func CreateFinder added in v0.0.4

func CreateFinder(g *git.Git, cfg *models.Config) *finder.Finder

CreateFinder creates a finder instance for local operations with the given git instance.

func CreateGlobalFinder added in v0.0.4

func CreateGlobalFinder(cfg *models.Config) *finder.Finder

CreateGlobalFinder creates a finder instance for global operations.

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately.

func ExecuteWithArgs added in v0.0.4

func ExecuteWithArgs(requiresGit bool, fn func(*CommandContext, *cobra.Command, []string) error) func(*cobra.Command, []string) error

ExecuteWithArgs is a variant that passes command arguments to the function.

func ExecuteWithContext added in v0.0.4

func ExecuteWithContext(requiresGit bool, fn func(*CommandContext) error) func(*cobra.Command, []string) error

ExecuteWithContext creates a command context and executes the provided function. This is the main wrapper function that eliminates boilerplate in command implementations.

func LaunchShell added in v0.0.8

func LaunchShell(dir string) error

LaunchShell launches an interactive shell in the specified directory. This function is used by commands that support the --stay flag.

Types

type CommandContext added in v0.0.4

type CommandContext struct {
	Config          *models.Config
	Git             *git.Git
	Printer         *ui.Printer
	WorktreeManager *worktree.Manager

	IsGitRepo bool
	// contains filtered or unexported fields
}

CommandContext encapsulates common dependencies used across commands. This eliminates boilerplate code and provides consistent initialization.

func NewCommandContext added in v0.0.4

func NewCommandContext() (*CommandContext, error)

NewCommandContext creates a new command context for commands that don't require git.

func NewGitCommandContext added in v0.0.4

func NewGitCommandContext() (*CommandContext, error)

NewGitCommandContext creates a new command context for commands that require git repository.

func (*CommandContext) DiscoverGlobalWorktrees added in v0.0.4

func (ctx *CommandContext) DiscoverGlobalWorktrees() ([]*models.Worktree, error)

DiscoverGlobalWorktrees discovers global worktrees when -g flag is used.

func (*CommandContext) GetFinder added in v0.0.4

func (ctx *CommandContext) GetFinder() *finder.Finder

GetFinder returns a finder instance, creating it if needed. This provides lazy initialization to avoid creating finders for commands that don't need them.

func (*CommandContext) GetGlobalFinder added in v0.0.4

func (ctx *CommandContext) GetGlobalFinder() *finder.Finder

GetGlobalFinder returns a finder instance for global operations that don't require a git repository. This creates a finder with an empty git instance, suitable for global worktree operations.

func (*CommandContext) GetWorktrees added in v0.0.4

func (ctx *CommandContext) GetWorktrees(forceGlobal bool) ([]*models.Worktree, error)

GetWorktrees returns worktrees with support for both global and local modes

func (*CommandContext) WithGlobalLocalSupport added in v0.0.4

func (ctx *CommandContext) WithGlobalLocalSupport(
	forceGlobal bool,
	localFn func(*CommandContext) error,
	globalFn func(*CommandContext) error,
) error

WithGlobalLocalSupport handles commands that support both global and local modes.

type StatusCollector added in v0.0.3

type StatusCollector struct {
	// contains filtered or unexported fields
}

StatusCollector collects status information for worktrees.

func NewStatusCollector added in v0.0.3

func NewStatusCollector(includeProcess, fetchRemote bool) *StatusCollector

NewStatusCollector creates a new status collector instance.

func NewStatusCollectorWithOptions added in v0.0.3

func NewStatusCollectorWithOptions(opts StatusCollectorOptions) *StatusCollector

NewStatusCollectorWithOptions creates a new status collector with custom options.

func (*StatusCollector) CollectAll added in v0.0.3

func (c *StatusCollector) CollectAll(ctx context.Context, worktrees []*models.Worktree) ([]*models.WorktreeStatus, error)

CollectAll collects status for all provided worktrees in parallel.

type StatusCollectorOptions added in v0.0.3

type StatusCollectorOptions struct {
	IncludeProcess bool
	FetchRemote    bool
	StaleThreshold time.Duration
	BaseDir        string
}

StatusCollectorOptions contains optional parameters for StatusCollector.

Jump to

Keyboard shortcuts

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