主题
cnb-rs issue comment <NUMBER> [flags]
在 Issue 上添加一条评论;或用 --edit-last / --id <CID> 编辑已有评论。借鉴 gh issue comment 的单命令 + flag 设计,比 gh 多一个能力:--id <CID> 可编辑任意 CID 的评论(gh 只能 --edit-last)。
--edit-last
--id <CID>
gh issue comment
历史:v0.13 ~ P0-5 之前,本命令是 issue comment {add | list | view | edit} 4 子命令组;P0-5 折叠为单命令。列举评论:留给 issue view --comments(CLI 上单查罕见,列举走 view 扩展即可)。CNB API 没有 delete_issue_comment,所以本命令不提供 --delete-last(与 gh issue comment 略有不同)。
历史:v0.13 ~ P0-5 之前,本命令是 issue comment {add | list | view | edit} 4 子命令组;P0-5 折叠为单命令。
issue comment {add | list | view | edit}
列举评论:留给 issue view --comments(CLI 上单查罕见,列举走 view 扩展即可)。
issue view --comments
CNB API 没有 delete_issue_comment,所以本命令不提供 --delete-last(与 gh issue comment 略有不同)。
delete_issue_comment
--delete-last
<NUMBER>
-b, --body <BODY>
--body-file
-F, --body-file <FILE>
-
--body
created_at
--id <COMMENT_ID>
--attach <FILE>
--id
--attach
至少需要传 -b 或 -F 之一,否则报错。
-b
-F
继承的全局选项:
--repo <REPO>
group/repo
--domain <DOMAIN>
cnb.cool
✓ 已在 Issue #N 上发表评论 (id=...)
✓ 已编辑 Issue #N 上的评论 (id=...)
# 添加一条评论 $ cnb-rs issue comment 42 -b "已确认问题,正在修复" ✓ 已在 Issue #42 上发表评论 (id=2055950878457462784) https://cnb.cool/org/repo/-/issues/42 # 从文件读 body(多行 markdown) $ cnb-rs issue comment 42 -F notes.md # 从 stdin 读(适合 pipe) $ echo "lgtm" | cnb-rs issue comment 42 -F - # 附件上传 $ cnb-rs issue comment 42 -b "补一个 trace" --attach trace.log # 编辑当前用户最近一条评论(typo 补救常用) $ cnb-rs issue comment 42 --edit-last -b "(edited) 已确认问题" ✓ 已编辑 Issue #42 上的评论 (id=2055950878457462784) # 编辑指定 CID 的评论(比 gh 多一个能力) $ cnb-rs issue comment 42 --id 2055886607480520704 -b "新内容" # 不传 body 报错 $ cnb-rs issue comment 42 错误: 请通过 -b/--body 或 -F/--body-file 提供评论正文 # --edit-last 与 --id 互斥(clap 拒绝) $ cnb-rs issue comment 42 --edit-last --id 12345 error: the argument '--edit-last' cannot be used with '--id <COMMENT_ID>' # --edit-last / --id 模式不能带 --attach $ cnb-rs issue comment 42 --edit-last -b "x" --attach trace.log 错误: --edit-last 模式不支持 --attach(编辑已存在评论加附件不在本命令范围内)
${API}/repos/{repo}/-/issues/{n}/comments
${API}/user
${API}/repos/{repo}/-/issues/{n}/comments/{cid}
--edit-last 总共 3 个 API 调用,前两个并发(tokio::join!)。
tokio::join!
与 issue create --attach 不同:评论附件没有 asset-group 批量 API,每个文件单独调 POST /{repo}/-/issues/{n}/comment-{file|image}-asset-upload-url 申请 upload URL,之后步骤一致(PUT 到 OSS → 拿 asset_link → 追加到 body 末尾)。
issue create --attach
POST /{repo}/-/issues/{n}/comment-{file|image}-asset-upload-url
asset_link
任何一步附件上传失败会直接中断,评论 不会被创建。
issue comment {add/list/view/edit}
issue comment add 42 -c "x"
issue comment 42 -b "x"
-c
issue comment add 42 -c "x" --attach FILE
issue comment 42 -b "x" --attach FILE
issue comment list 42
issue view 42 --comments
issue comment view 42 <CID>
issue comment edit 42 <CID> -c "x"
issue comment 42 --id <CID> -b "x"
$ cnb-rs issue comment list 42 error: unexpected argument '42' found # 因为 list 被认为是 NUMBER,42 被认为是位置参数多余
clap 直接拒绝,提示用户改用新单命令。
issue close / issue reopen 也接受 -c "评论" 选项,在状态变更前先发评论;本命令是独立的「只发评论」单命令。
issue close
issue reopen
-c "评论"
--comments
cnb-rs issue comment
在 Issue 上添加一条评论;或用
--edit-last/--id <CID>编辑已有评论。借鉴gh issue comment的单命令 + flag 设计,比 gh 多一个能力:--id <CID>可编辑任意 CID 的评论(gh 只能--edit-last)。选项
<NUMBER>:Issue 编号(必填)-b, --body <BODY>:评论正文;与--body-file互斥-F, --body-file <FILE>:从文件读评论正文;-表示从 stdin 读;与--body互斥--edit-last:编辑当前用户在该 Issue 上最近一条评论(按created_at取最新),找不到则报错--id <COMMENT_ID>:编辑指定 ID 的评论;与--edit-last互斥;比 gh 多一个能力--attach <FILE>:附件文件路径(仅新增评论模式下生效;--edit-last/--id时传--attach会报错)至少需要传
-b或-F之一,否则报错。继承的全局选项:
--repo <REPO>:指定仓库路径(格式:group/repo)--domain <DOMAIN>:指定目标域名(默认:cnb.cool)输出约定
✓ 已在 Issue #N 上发表评论 (id=...)✓ 已编辑 Issue #N 上的评论 (id=...)示例
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
API 调用
${API}/repos/{repo}/-/issues/{n}/comments--edit-last找最近${API}/user+${API}/repos/{repo}/-/issues/{n}/comments--edit-lastpatch${API}/repos/{repo}/-/issues/{n}/comments/{cid}--idpatch${API}/repos/{repo}/-/issues/{n}/comments/{cid}--attach--edit-last总共 3 个 API 调用,前两个并发(tokio::join!)。附件上传工作流(仅新增模式)
与
issue create --attach不同:评论附件没有 asset-group 批量 API,每个文件单独调POST /{repo}/-/issues/{n}/comment-{file|image}-asset-upload-url申请 upload URL,之后步骤一致(PUT 到 OSS → 拿asset_link→ 追加到 body 末尾)。任何一步附件上传失败会直接中断,评论 不会被创建。
迁移指南
从 P0-5 之前的
issue comment {add/list/view/edit}子命令组 issue comment add 42 -c "x"issue comment 42 -b "x"(注意-c→-b)issue comment add 42 -c "x" --attach FILEissue comment 42 -b "x" --attach FILEissue comment list 42issue view 42 --commentsissue comment view 42 <CID>issue view 42 --comments后人眼找(CNB 无独立 comment view URL)issue comment edit 42 <CID> -c "x"issue comment 42 --id <CID> -b "x"(cnb-rs 保留任意 CID 编辑能力,比 gh 多)旧用法 fail 行为
2
clap 直接拒绝,提示用户改用新单命令。
关联命令
issue close/issue reopen也接受-c "评论"选项,在状态变更前先发评论;本命令是独立的「只发评论」单命令。另请参阅
--comments查看 issue 上所有评论