Repository navigation
管理器:从终端启动时输出用法和参数错误 - #206
Merged
Merged
Conversation
parseArgs 解析 main 现有的全部选项,行为和 main 一致;用法、参数错误 (包括更新交接 ID 不对、端口越界)照旧按重定向、父进程终端、弹框的顺序输出。 Refs ModAVD/ModAVD#258
qiyinxi
marked this pull request as ready for review
November 27, 2026 14:20
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么 / What changed
图形管理器
ModAVD.exe的用法和参数错误以前只能弹框看。现在(Windows)按下面的顺序找地方输出:退出码不变:
--help/-h/-help是 0,参数不对是 2。cmd/modavd-gui/main.go:命令行解析拆成parseArgs,解析 main 现有的全部选项,每一项的行为和 main 一样:--root、--port(0–65535)、--no-window、--dev、只在 macOS arm64 上有的--chrome-window、更新交接 IDupdate.HandoffArg(用update.ParseHandoffID核对,不对就退出码 2)。--help照旧不列交接 ID。解析完的结果照旧交给reopen、reopenArgs和ui.Options(含Tray)。cmd/modavd-gui/msgbox.go:fatal/notice仍是变量(测试替换用),默认先试writeText,写不出去才弹框;写出去的文字和弹框一样先经过i18n.T翻译。启动以后的错误(找不到根目录、已有管理器但读不到地址等)也走这条路。cmd/modavd-gui/output_windows.go:按标准流的文件类型选输出(磁盘文件、管道、不是控制台的字符设备算重定向);挂父进程控制台用AttachConsole(ATTACH_PARENT_PROCESS),写CONOUT$(按 UTF-16 写控制台,跟代码页无关)。output_other.go:别的平台不变,照旧弹框。Start-Process -Wait -PassThru加重定向)。changelog.d/258-cli-output.change.md。怎么验证的 / How it was verified
go vet ./...、go test ./...(Windows),go test -c -o NUL ./cmd/modavd-gui,GOOS=darwin GOARCH=arm64和GOOS=linux GOARCH=amd64的go vet ./...,gofmt -l无输出:都过。args_test.go(不分平台):--help、-h退出码 0、不算错误;--bogus、--port缺值、多余参数、--port 70000、--port -1、交接 ID 不对(格式不对、大写、缺值)、--chrome-window(Windows、Linux 上没有这个选项;macOS arm64 上有)都是退出码 2、算错误;带齐全部选项(含合法交接 ID)时解析结果正确;--help不列交接 ID。output_windows_test.go:routeText的六种情况(文件、管道、NUL、控制台句柄、没重定向但有父控制台、双击);把 stdout、stderr 换成临时文件、弹框换成「弹了就算失败」,经run()跑--help(退出码 0,用法只进 stdout)、--bogus、--port 70000、交接 ID 不对、--chrome-window(退出码 2,错误只进 stderr),并且没有弹框。help_test.go(fatal/notice换掉后的弹框内容和退出码)照旧通过。-H=windowsgui)放进临时目录,只跑重定向的情况:用Start-Process -PassThru -RedirectStandardOutput/-RedirectStandardError启动,记下 PID,10 秒没退就按 PID 结束、算失败。结果三项都在 10 秒内退出:--help:退出码 0,用法在 stdout 文件里,stderr 为空;--bogus:退出码 2,「命令行参数不对:flag provided but not defined: -bogus」和用法在 stderr 文件里,stdout 为空;--update-handoff bad:退出码 2,交接 ID 的错误在 stderr 文件里,stdout 为空。routeText的单测。核对 / Checklist
changelog.d/<名字>.<feat|fix|change|remove>.md(只动开发、测试、CI、文档的不用) / A change users can see comes withchangelog.d/<name>.<feat|fix|change|remove>.md(not needed for development, tests, CI or docs)X.md、X.en.md)两份都改了;只会一种语言的在上面说一声 / Both files of a Chinese / English pair (X.md,X.en.md) are changed; if you write only one of the languages, say so aboveRefs ModAVD/ModAVD#258