cli

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli 解析命令并把工作委派给应用服务。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, args []string, io IO, optionValues ...Option) int

Execute 执行一次 Runtime 顶层命令并返回进程退出码。 解析失败时向 stderr 写诊断并返回 2;协议不兼容返回 10; 解析成功后统一进入 hello → 执行 → result 生命周期。

Types

type IO

type IO struct {
	In  io.Reader
	Out io.Writer
	Err io.Writer
}

IO 显式注入单次执行的 stdin、stdout 与 stderr。

type Option

type Option func(*options) error

Option 配置 Execute 的可注入测试依赖。

func WithBackendFactory

func WithBackendFactory(factory backendFactory) Option

WithBackendFactory 注入后端监督器工厂,供命令契约测试隔离真实 Job 与端口。

func WithCWD

func WithCWD(cwd string) Option

WithCWD 注入相对 --app-root 的解析基准目录。

func WithClock

func WithClock(clock func() time.Time) Option

WithClock 注入协议事件时钟,主要供测试使用。

func WithDoctorFactory

func WithDoctorFactory(factory doctorFactory) Option

WithDoctorFactory 注入 doctor 服务工厂,主要供契约测试替换服务替身。

func WithEnvironmentFactory

func WithEnvironmentFactory(factory environmentFactory) Option

WithEnvironmentFactory 注入 M5 环境服务,供命令测试隔离真实 uv/Python。

func WithEnvironmentStateStoreFactory

func WithEnvironmentStateStoreFactory(factory environmentStateStoreFactory) Option

WithEnvironmentStateStoreFactory 注入 M5 稳定状态存储。

func WithMutationCoordinatorFactory

func WithMutationCoordinatorFactory(factory mutationCoordinatorFactory) Option

WithMutationCoordinatorFactory 注入 M5 mutation 锁协调器。

func WithTelemetryFactory

func WithTelemetryFactory(factory telemetryFactory) Option

WithTelemetryFactory 注入遥测观察器工厂,供会话测试隔离真实 SDK 和网络。

func WithVersionSource

func WithVersionSource(source versionSourceFunc) Option

WithVersionSource 注入版本信息来源,默认使用 version.Load。

func WithWorkspaceFactory

func WithWorkspaceFactory(factory workspaceFactory) Option

WithWorkspaceFactory 注入 workspace 服务工厂,供命令与契约测试隔离真实 Git/Mutex。

func WithWorkspaceLoggerFactory

func WithWorkspaceLoggerFactory(factory workspaceLoggerFactory) Option

WithWorkspaceLoggerFactory 注入 Runtime logger 工厂,主要供取消与契约测试使用。

Jump to

Keyboard shortcuts

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