fix(cli): show help for subcommands missing arguments - #428
Merged
Merged
Conversation
Subcommand validation ran before --help was honored, so commands such as `qwenaudio install --help` printed a missing-argument error instead of the help text. Fall back to help when parsing fails for a known command that explicitly asks for it; other errors are reported unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
x-lixu
approved these changes
Sep 17, 2026
x-lixu
left a comment
Collaborator
There was a problem hiding this comment.
感谢修复子命令帮助入口。已验证四类缺参帮助调用以 0 退出,普通缺参和未知命令仍报错;本地参数测试和代码检查通过,更新 main 后的各平台 CI 也已通过,审查通过。
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.
变更说明
现象:对需要位置参数的子命令查看帮助时,CLI 直接报错退出,而不是显示帮助:
而
qwenaudio tui --help、qwenaudio --help可以正常显示帮助。原因:
parseArguments()先消费子命令的位置参数并执行“缺少参数”“选项只适用于某命令”等校验,--help只在后面的循环里记录为options.help。校验提前抛错时,launcher 永远到不了if (options.help)分支。launcher 已经把任何带--help/-h的调用视为只读命令,说明帮助本应在参数不完整时也可用。修复:保持原有解析与校验逻辑不变,外层在解析抛错且参数中包含
--help/-h、命令本身合法时,返回{ command, help: true },由 launcher 显示帮助。未请求帮助时仍报告原来的错误;未知命令带--help仍报“未知命令”。验证
本机 Windows 11,Node 24.17.0。
新增测试
shows help for subcommands that otherwise require arguments,覆盖上述四个子命令,并确认不带--help的install与带--help的未知命令仍然报错。修复前:
修复后:
node --test cli/test/arguments.test.mjs(21 通过)node cli/bin/qwenaudio.mjs install --help等四个命令均输出帮助并以 0 退出npm test(根目录与 server 工作区 1467 项:1464 通过、2 跳过、1 失败;其余工作区 899 项:882 通过、17 跳过、0 失败。唯一失败的server/test/frontend-notes.test.mjs跨进程文件锁用例只在 Windows 整轮高负载下超时,与本改动无关:单独连续运行 3 次均通过,且在未改动的 upstream/main 上整轮运行两次也复现一次同样的超时)npm run lintnpm run build兼容性与安全
--help/-h且原本会解析失败的 CLI 调用;launcher 已按只读方式加载这类调用的环境,不涉及网络、权限、持久化或进程管理。回滚:还原本 PR。🤖 Generated with Claude Code