Commit 92806ec
authored
refactor: convert list command handlers to return data instead of writing stdout (#404)
## Summary
Converts all list command handlers from writing directly to stdout to
returning `ListResult<T>` data structures. The calling framework
(`buildOrgListCommand` / `OutputConfig`) handles rendering based on
`--json` vs human mode.
This is Phase 6a of the structured output migration — making list
commands return data so we can enforce the "commands never touch stdout"
rule.
## Changes
### New infrastructure
- **`formatTable()`** in `table.ts` — returns a formatted table string
instead of writing to a stream. `writeTable()` now delegates to it.
- **`ListResult<T>`** type in `org-list.ts` — captures items, pagination
metadata, hints, headers, and errors.
- **`formatListHuman()` / `transformListJson()`** in `list-command.ts` —
shared formatters for the `OutputConfig` pipeline.
### Refactored files
| File | Change |
|------|--------|
| `org-list.ts` | All 5 default handlers return `ListResult` instead of
writing stdout. `OrgListConfig.displayTable` returns string.
`ModeHandler` return type updated. |
| `list-command.ts` | `buildOrgListCommand` uses full
`OutputConfig<ListResult<TWithOrg>>` with human/jsonTransform. |
| `team/list.ts` | `displayTable` uses `formatTable()` (returns string)
|
| `repo/list.ts` | `displayTable` uses `formatTable()` (returns string)
|
| `project/list.ts` | All 4 custom handlers return
`ListResult<ProjectWithOrg>`. Full `OutputConfig`. |
| `issue/list.ts` | Extended `IssueListResult` type. Both handler paths
return data. Full `OutputConfig` with `formatIssueListHuman` /
`jsonTransformIssueList`. |
### Backwards compatibility
- `ModeHandler` returns `Promise<ListResult<unknown> | void>` — legacy
void-returning handlers (e.g., `log/list`) still work.
- `stdout` kept in `HandlerContext` for `log/list` which is not yet
migrated.
- All existing test assertions preserved; test files updated for new
return types.
## Remaining work (future PRs)
- **Phase 6b**: Migrate `log/list` (streaming `--follow` mode needs
`buildStreamingCommand`)
- **Phase 6c**: Remove `stdout` from `HandlerContext` once all consumers
migrated
## Verification
- TypeScript: 0 errors
- Lint: 0 issues (355 files)
- 788 related tests pass across 25 test files
- No regressions vs main (184 pre-existing failures on branch vs 234 on
main)1 parent fe755ee commit 92806ec
File tree
10 files changed
+933
-932
lines changed- src
- commands
- issue
- project
- repo
- team
- lib
- formatters
- test
- commands/project
- lib
10 files changed
+933
-932
lines changedLarge diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
97 | | - | |
| 103 | + | |
98 | 104 | | |
99 | | - | |
100 | | - | |
| 105 | + | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
| |||
109 | 114 | | |
110 | 115 | | |
111 | 116 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
121 | 139 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
403 | 408 | | |
404 | 409 | | |
405 | 410 | | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
406 | 446 | | |
407 | 447 | | |
408 | 448 | | |
409 | 449 | | |
410 | 450 | | |
411 | | - | |
| 451 | + | |
412 | 452 | | |
413 | 453 | | |
414 | 454 | | |
415 | 455 | | |
416 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
417 | 459 | | |
418 | 460 | | |
419 | 461 | | |
| 462 | + | |
420 | 463 | | |
421 | 464 | | |
422 | 465 | | |
| |||
425 | 468 | | |
426 | 469 | | |
427 | 470 | | |
428 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
429 | 477 | | |
430 | 478 | | |
431 | 479 | | |
| |||
445 | 493 | | |
446 | 494 | | |
447 | 495 | | |
448 | | - | |
| 496 | + | |
449 | 497 | | |
450 | 498 | | |
451 | 499 | | |
452 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
453 | 511 | | |
454 | 512 | | |
455 | 513 | | |
0 commit comments