cmd

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package cmd implements all CLI commands for the work tool.

External capabilities (network, filesystem, terminal) are injected via the Deps struct. Production code uses NewDeps(); tests construct their own via newTestDeps(t) and override individual fields. This makes tests independent and safe for parallel execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRootCmd

func NewRootCmd(version string, deps *Deps) *cobra.Command

NewRootCmd creates the top-level work command.

Types

type Deps added in v1.4.0

type Deps struct {
	IsInteractive      func() bool
	AutoUpdate         func(context.Context, cache.UpdateConfig, *cache.Cache, cache.UpdateOptions) (*cache.Cache, error)
	ShowUpdateProgress func(context.Context, *Deps, cache.UpdateConfig, *cache.Cache, cache.UpdateOptions) (*cache.Cache, error)
	SelectRepo         func([]cache.SearchResult, string) (*cache.Repo, bool)
	OpenURL            func(string) error
	OpenFile           func(string) error
	EditFile           func(string) error
	SyncRepo           func(string) git.SyncResult
	GhAuthLogin        func(string) error
	DetectToken        func(string) (*auth.Token, error)
	GhAuthLogout       func(string) error
	PromptWorkDir      func(string) (string, error)
	PromptConfirm      func(string) (bool, error)
	SelectDomain       func([]string) (string, error)
	SelectOrgs         func([]string, []string) ([]string, error)
	ListOrgs           func(string, string) ([]string, error)
	FetchRepo          func(ctx context.Context, domain, token, owner, name string) (*cache.Repo, error)
	RunAboutProgram    func(string) error
	PickAboutStyle     func() aboutStyle
}

Deps holds all external capabilities that command handlers need. Production code uses NewDeps(); tests construct their own with safe-for-tests defaults via TestDeps(t) and override individual fields.

func NewDeps added in v1.4.0

func NewDeps() *Deps

NewDeps creates a Deps wired with production implementations.

func (*Deps) TokenForDomain added in v1.4.0

func (d *Deps) TokenForDomain(domain string) (string, error)

TokenForDomain returns a token string for the given domain, derived from DetectToken. Used by ensureCache for the auto-update token func.

Jump to

Keyboard shortcuts

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