cli

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 27 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 承载 windshare 的子命令逻辑(执行计划 §6.9)。与 main 分离: IO(stdin/stdout/stderr)全部注入,命令函数返回退出码而非直接 os.Exit, 集成测试得以在进程内驱动完整 share/get 流程(DfT)。

Index

Constants

View Source
const (
	ExitOK      = 0
	ExitFailure = 1 // 运行期失败:传输中断、本地 IO、内部错误
	ExitUsage   = 2 // 用户错误:参数、链接/密钥、路径选择、清单超限
	ExitNetwork = 3 // 网络/中转不可达或被中转拒绝
	ExitDrift   = 4 // 快照漂移中止:分享期间文件被修改(§6.3)
)

退出码语义(§6.9 工程要求):脚本据此区分"该重试"(网络)与"该改命令" (用户错误)与"该重新分享"(漂移)。

View Source
const (
	// DefaultRelayURL 与 wsrelay 的默认监听端口(:8484)对齐。
	DefaultRelayURL = "ws://127.0.0.1:8484"
	// DefaultFrontURL 是链接的前端基址占位(Vite 开发服务器默认端口)。
	DefaultFrontURL = "http://localhost:5173"
)

部署期默认值:M1 无注册域名,一律指向本机开发环境(§6.3"前端域为 部署期配置")。

Variables

This section is empty.

Functions

func Main

func Main() int

Main 是 os 进程入口的接线:真实标准流 + SIGINT 取消(Ctrl-C 即"停止分享" /"中断下载"语义,§6.9)。

Types

type App

type App struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// RejoinWindow 覆盖传输中断后 rejoin 的退避总窗(零值取生产默认
	// rejoinWindow)。注入点只为测试收短时序,不是用户面配置。
	RejoinWindow time.Duration
	// contains filtered or unexported fields
}

App 是一次 CLI 调用的执行环境;字段即全部外部依赖。

func (*App) Run

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

Run 分派子命令。stdlib flag 不认子命令,这里手工分派(§6.9 工程要求: 不引 CLI 框架)。

Jump to

Keyboard shortcuts

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