已关闭
feat: 添加输出模板系统支持 #127
aflyingto创建于 4月5日关闭于 4月7日
aflyingto
4月7日 评论:
4月7日 评论:
阶段记录
- 阶段: ready-for-review
- 结论: PR #95 已补上
gc issue list --template的可用入口,并配套冲突校验、帮助信息、文档和回归验证;issue 127 进入独立执行主体评审。 - 证据:
- 关联 PR: !95
- 提交:
bce2821 feat: complete issue output contracts and view details - 验证:
go test ./...、go build -o ./gc ./cmd/gc - 实际命令:
./gc issue list -R infra-test/gctest1 --limit 1 --template '{{range .}}{{.Number}} {{.Title}}{{"\\n"}}{{end}}' - 错误路径:
./gc issue list -R infra-test/gctest1 --json --template '{{.}}'返回稳定用法错误
- 下一步: 等待独立执行主体评审;如需要更强模板能力,可后续补 preset 模板与额外 helper。
开发进度
- 根因: 现有 CLI 缺少可控的模板输出入口,之前分支虽然引入了模板代码,但没有真实暴露到命令层。
- 主要修改: 为
issue list增加--template,并明确其与--json、--format互斥;内置upper、lower、trunc、json、timehelper。 - 测试:
go test ./... - 实际命令验证: 同上
- 安全影响: 无认证、权限或危险写路径变更
- 风险或未覆盖项: 本次未实现 issue 建议中的 preset 模板与
yamlhelper,后续如有需要可单独补齐。 - 关联 PR: !95


aflyingto
4月7日 评论:
4月7日 评论:
aflyingto
5月1日 评论:
5月1日 评论:
问题描述
用户无法自定义输出格式,限制了 CLI 的灵活性。
建议方案
添加
--template选项,支持 Go 模板语法:# 自定义输出格式 $ gc issue list --template '{{.Number}}: {{.Title}} ({{.State}})' # 输出到文件 $ gc issue list --template '{{range .}}{{.Number}},{{.Title}}{{println}}{{end}}' > issues.csv # JSON 格式化 $ gc issue list --template '{{json .}}'实现方案
text/template包预设模板
# 使用预设模板 $ gc issue list --template preset:csv $ gc issue list --template preset:tsv $ gc issue list --template preset:markdown参考实现
gh issue list --templatekubectl get -o go-template优先级
中