@cloudbase/cli 3.0.0-alpha.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,36 @@ yarn global add @cloudbase/cli
42
42
 
43
43
  请访问[教程与文档](https://docs.cloudbase.net/cli/intro.html)了解详细的使用方法。
44
44
 
45
+ ## 退出码说明
46
+
47
+ CloudBase CLI 使用结构化退出码帮助 CI/CD 流水线和 AI Agent 精确处理错误:
48
+
49
+ | 退出码 | 含义 | 典型场景 | 应对策略 |
50
+ |--------|------|----------|----------|
51
+ | 0 | 成功 | 命令正常执行 | - |
52
+ | 1 | 通用错误 | 未分类的异常 | 查看错误信息,手动排查 |
53
+ | 2 | 认证失败 | 未登录、token 过期、无权限 | 执行 `tcb login` 重新登录 |
54
+ | 3 | 参数错误 | 缺少必填参数、格式非法、枚举值错误 | 检查命令参数,参考 `tcb <cmd> --help` |
55
+ | 4 | 资源不存在 | 环境 ID/函数名无效、集合不存在 | 确认资源名称,用 `tcb env list` / `tcb fn list` 验证 |
56
+ | 5 | 云 API 错误 | CloudBase API 返回错误、网络超时 | 检查网络连接,查看 API 错误详情,必要时重试 |
57
+ | 6 | 本地文件错误 | cloudbaserc.json 缺失/损坏、路径不存在 | 检查配置文件,用 `tcb init` 重新初始化 |
58
+
59
+ **CI/CD 脚本示例**:
60
+
61
+ ```bash
62
+ # 根据退出码自动重试
63
+ tcb fn deploy || {
64
+ code=$?
65
+ case $code in
66
+ 2) echo "Auth failed, retrying..." && tcb login && tcb fn deploy ;;
67
+ 5) echo "API error, retrying in 30s..." && sleep 30 && tcb fn deploy ;;
68
+ *) echo "Unrecoverable error (code $code)" && exit $code ;;
69
+ esac
70
+ }
71
+ ```
72
+
73
+ 完整定义参见:[src/exit-codes.ts](./src/exit-codes.ts)
74
+
45
75
  ## 意见反馈
46
76
 
47
77
  您可以到 GitHub Repo 新建一个 [issue](https://github.com/TencentCloudBase/cloudbase-cli/issues) 反馈您在使用过程中遇到的问题或建议。