Documentation
¶
Overview ¶
Package cmd provides CLI commands for the gwq application.
Index ¶
- Constants
- func CreateFinder(g *git.Git, cfg *models.Config) *finder.Finder
- func CreateGlobalFinder(cfg *models.Config) *finder.Finder
- func Execute()
- func ExecuteWithArgs(requiresGit bool, fn func(*CommandContext, *cobra.Command, []string) error) func(*cobra.Command, []string) error
- func ExecuteWithContext(requiresGit bool, fn func(*CommandContext) error) func(*cobra.Command, []string) error
- func LaunchShell(dir string) error
- type CommandContext
- func (ctx *CommandContext) DiscoverGlobalWorktrees() ([]*models.Worktree, error)
- func (ctx *CommandContext) GetFinder() *finder.Finder
- func (ctx *CommandContext) GetGlobalFinder() *finder.Finder
- func (ctx *CommandContext) GetWorktrees(forceGlobal bool) ([]*models.Worktree, error)
- func (ctx *CommandContext) WithGlobalLocalSupport(forceGlobal bool, localFn func(*CommandContext) error, ...) error
- type StatusCollector
- type StatusCollectorOptions
Constants ¶
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
CreateFinder creates a finder instance for local operations with the given git instance.
func CreateGlobalFinder ¶ added in v0.0.4
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
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.