cli

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package cli 是终端 Agent 的命令行:独立二进制 relaymesh-agent 与主程序的 `relaymesh agent` 子命令共用同一份实现。

退出码约定:0 成功;1 运行期失败;2 用法错误。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, args []string, env Env) int

Run 解析并执行命令,返回进程退出码。

Types

type Env

type Env struct {
	// Version 是 Agent 版本号。
	Version string
	// Rev 是 Agent 二进制的「Agent 侧代码指纹」(见 termproto.ValidAgentRev);空表示非发布构建。
	// 它决定「要不要升级 / 守护进程要不要重启」:指纹一致说明两边的 Agent 代码相同,版本号不同只是构建号不同。
	Rev string
	// Prog 是帮助与提示里出现的命令名,例如 "relaymesh-agent" 或 "relaymesh agent"。
	Prog string
	// ServiceArgs 是服务单元里跟在可执行文件之后的前缀参数:独立二进制为空,主程序子命令为 ["agent"]。
	ServiceArgs []string

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	// Getenv 读取环境变量;为 nil 时使用 os.Getenv(测试注入)。
	Getenv func(string) string
}

Env 是命令行的运行环境。

Jump to

Keyboard shortcuts

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