fix(output): --format table 支持资源包裹列表响应(此前 list 命令表格从不生效) #343

Merged
wbtiger merged 1 commits from Taoyouce/gitlink-cli:feat/table-list-rendering into master 2026-07-14 20:43:47 +08:00
Contributor

问题

平台所有分页列表端点的响应形状都是资源包裹 map:{"total_count": N, "<资源名>": [...]}printTable 遇到含嵌套结构的 map 一律回落 JSON,导致 所有 list 命令的 --format table 实际上从不渲染表格,与 flag 文案承诺不符。

修复

  • 检测「恰好一个数组值 + 其余全是标量」的 map(列表响应形状):先打印标量摘要行(如 total_count: 7,键排序),再把包裹数组渲染为表格
  • 含嵌套对象的 map(如 commit 详情)与既有行为一致回落 JSON

生产实测

branch +list --format table(forgeplus):输出 total_count: 7 摘要行 + 7 行分支表格(此前输出整段 JSON)。

测试

formatter_test.go 新增 2 个单测;全量 go test/vet/gofmt 通过。

## 问题 平台所有分页列表端点的响应形状都是资源包裹 map:`{"total_count": N, "<资源名>": [...]}`。`printTable` 遇到含嵌套结构的 map 一律回落 JSON,导致 **所有 list 命令的 `--format table` 实际上从不渲染表格**,与 flag 文案承诺不符。 ## 修复 - 检测「恰好一个数组值 + 其余全是标量」的 map(列表响应形状):先打印标量摘要行(如 `total_count: 7`,键排序),再把包裹数组渲染为表格 - 含嵌套对象的 map(如 commit 详情)与既有行为一致回落 JSON ## 生产实测 `branch +list --format table`(forgeplus):输出 `total_count: 7` 摘要行 + 7 行分支表格(此前输出整段 JSON)。 ## 测试 formatter_test.go 新增 2 个单测;全量 go test/vet/gofmt 通过。
Taoyouce added 4 commits 2026-07-06 07:28:33 +08:00
wbtiger merged commit b44eaa220e into master 2026-07-14 20:43:39 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#343
No description provided.