cli

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cli wires commit-spark's command-line surface and orchestrates its commands. All external effects reach it through the injected Git and Codex interfaces, so the command flows are unit-testable with fakes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOpenBrowser

func DefaultOpenBrowser(ctx context.Context, target string) error

DefaultOpenBrowser opens target in the OS default browser.

Types

type App

type App struct {
	Version string

	Git   Git
	Codex Codex

	// ConfigPath is the absolute path to the config file. ConfigDefaults holds
	// the effective defaults (including the OS-detected locale) that a missing
	// config key falls back to.
	ConfigPath     string
	ConfigDefaults config.Config

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	// Interactive is true when attached to a TTY (decided once in main).
	Interactive bool

	// OpenBrowser opens a URL; main wires DefaultOpenBrowser.
	OpenBrowser func(ctx context.Context, url string) error
}

App holds every dependency and configuration the commands need.

func (*App) PrintError

func (a *App) PrintError(err error)

PrintError writes err to Stderr. A *apperr.UserError is shown as a single line; any other error additionally gets a version + bug-report footer.

func (*App) Run

func (a *App) Run(ctx context.Context, args []string) error

Run builds the command tree and executes it with the given arguments (args[0] is the program name).

type Codex

type Codex interface {
	Generate(ctx context.Context, req codex.Request) (string, error)
}

Codex is the sole path to the LLM. codex.Client satisfies it.

type Git

type Git interface {
	RepoRoot(ctx context.Context) (string, error)
	StageAll(ctx context.Context) error
	StagedDiff(ctx context.Context, excludes []string) (*git.StagedDiff, error)
	Commit(ctx context.Context, message string) error
	Push(ctx context.Context) error
	CurrentBranch(ctx context.Context) (string, error)
	RemoteURL(ctx context.Context, name string) (string, error)
	DefaultBranch(ctx context.Context) (string, error)
	DiffRange(ctx context.Context, rangeSpec string) (string, error)
	PushUpstream(ctx context.Context, branch string) error
}

Git is the set of git operations csp needs. *git.Client satisfies it; tests inject a fake.

Jump to

Keyboard shortcuts

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