Repository navigation
feat(cli): 机器可读错误与退出码语义 - #4
Merged
Merged
Conversation
新增 CliError / toErrorShape,错误带 code / path / hint / details / exitCode; --json 时错误以结构化 JSON 只写 stderr。退出码统一为 0 成功 / 1 执行失败 / 2 用法或配置错误,无命令与未知命令从 1 改为 2,未知命令给最近候选。 同时明确本包不发 bin、不做命令发现:各产品包自带入口。
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.
Summary
CliError/toErrorShape:错误带code/path/hint/details/exitCode;普通异常退化为code: 'ERROR'。--json作为保留布尔 flag:错误以{ "error": { … } }只写 stderr,不污染 stdout。Test plan
pnpm checkpnpm test(19 passed)pnpm build(attw / publint 通过)兼容性
0.x minor:无命令 / 未知命令退出码由 1 变为 2,README 与 CHANGELOG 已写迁移说明。