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

cli

package
v0.16.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cli parses command-line input and renders stable human and JSON output for GitContribute application services.

The package defines adapter-facing request and result contracts but does not own persistence, network, or contribution-workflow decisions. Commands make side effects visible through their names and flags.

Index

Constants

View Source
const (
	ExitOK        = 0
	ExitGeneral   = 1
	ExitUsage     = 2
	ExitNotFound  = 3
	ExitNotWired  = 4
	ExitCancelled = 130
)

Exit codes returned by the CLI.

Variables

View Source
var ErrNotWired = errors.New("not wired: integration not yet implemented")

ErrNotWired reports that an optional capability is unavailable from the connected service or runner.

View Source
var ErrSetupCancelled = errors.New("setup cancelled")

ErrSetupCancelled reports a deliberate interactive cancellation.

Functions

func NewCLIError

func NewCLIError(code int, err error) error

NewCLIError returns an error with a specific exit code.

Types

type CLI

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

CLI is a Kong-based adapter that parses arguments and dispatches to product- owned application services. It owns no domain logic.

func New

func New(service contracts.Service, runner contracts.MCPRunner, stdout, stderr io.Writer) *CLI

New constructs a CLI that writes results to stdout and progress to stderr.

func (*CLI) Run

func (c *CLI) Run(ctx context.Context, args []string) error

Run parses arguments and dispatches to the appropriate Service or MCPRunner method. It respects context cancellation.

func (*CLI) SetInput

func (c *CLI) SetInput(input io.Reader)

SetInput replaces stdin for commands that explicitly import from "-".

func (*CLI) SetLogger

func (c *CLI) SetLogger(logger *slog.Logger)

SetLogger configures a structured logger for the CLI adapter.

func (*CLI) SetSetupPrompter added in v0.3.0

func (c *CLI) SetSetupPrompter(prompter SetupPrompter)

SetSetupPrompter replaces the interactive setup adapter. It is intended for tests and alternate accessible frontends.

func (*CLI) SetTUIRunner

func (c *CLI) SetTUIRunner(runner contracts.TUIRunner)

SetTUIRunner wires the optional terminal UI adapter.

type CLIError

type CLIError struct {
	Code int
	Err  error
}

CLIError attaches a stable exit code to an error.

func (*CLIError) Error

func (e *CLIError) Error() string

func (*CLIError) Unwrap

func (e *CLIError) Unwrap() error

type SetupPromptQuestion added in v0.3.0

type SetupPromptQuestion string

SetupPromptQuestion identifies one unresolved onboarding decision.

const (
	// SetupQuestionAccess asks where GitContribute should be available.
	SetupQuestionAccess SetupPromptQuestion = "access"
	// SetupQuestionClients asks which detected clients to configure.
	SetupQuestionClients SetupPromptQuestion = "clients"
	// SetupQuestionAuth asks how later sync commands should authenticate.
	SetupQuestionAuth SetupPromptQuestion = "auth"
)

type SetupPromptRequest added in v0.3.0

type SetupPromptRequest struct {
	Discovery      contracts.SetupDiscovery
	PackageRunner  bool
	Questions      []SetupPromptQuestion
	Mode           contracts.SetupMode
	Clients        []string
	TokenSource    string
	TokenSourceKey string
}

SetupPromptRequest contains resolved flags plus the questions that still require interactive consent.

type SetupPrompter added in v0.3.0

type SetupPrompter interface {
	Select(context.Context, SetupPromptRequest) (SetupSelection, error)
	Confirm(context.Context, string) (bool, error)
}

SetupPrompter owns interactive terminal mechanics. Application services never depend on Huh, Bubble Tea, or terminal styling types.

type SetupSelection added in v0.3.0

type SetupSelection struct {
	Mode           contracts.SetupMode
	Clients        []string
	TokenSource    string
	TokenSourceKey string
}

SetupSelection is the typed result of the interactive setup form.

Jump to

Keyboard shortcuts

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