Commit 5e68615
committed
feat: centralize --json/--fields injection via output: "json" on buildCommand
Lift --json and --fields flag definitions out of 17 individual commands
into buildCommand's output mode system. When a command declares
output: "json", the wrapper automatically:
- Injects --json (boolean) and --fields (parsed) flags
- Pre-parses --fields from comma-string to string[] before func runs
- Respects command-owned --json flags (skips injection, still adds --fields)
Also introduces writeJsonList() helper that applies --fields filtering
to each array element inside the {data, hasMore} wrapper, fixing the
BugBot-reported issue where filtering operated on the wrapper instead
of the nested data.
Changes:
- src/lib/command.ts: JSON_FLAG, FIELDS_FLAG constants, output mode logic
- src/lib/formatters/json.ts: writeJsonList() with extra? option
- src/lib/formatters/output.ts: fields? on WriteOutputOptions
- src/lib/list-command.ts: passes output through to buildCommand
- src/lib/org-list.ts: fields on BaseListFlags, writeJsonList at wrapper site
- 17 command files: migrated to output: "json", removed manual flag defs
- 3 commands gained --fields: auth/refresh, org/view, trace/logs
- test/lib/command.test.ts: 14 new tests for json injection + fields parsing
- test/lib/formatters/json.test.ts: 17 new tests for writeJsonList1 parent 901bf44 commit 5e68615
File tree
25 files changed
+822
-275
lines changed- src
- commands
- auth
- event
- issue
- log
- org
- project
- trace
- lib
- formatters
- test/lib
- formatters
25 files changed
+822
-275
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
651 | 654 | | |
652 | 655 | | |
653 | 656 | | |
| |||
659 | 662 | | |
660 | 663 | | |
661 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
662 | 668 | | |
663 | 669 | | |
664 | 670 | | |
| 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 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
| |||
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
106 | | - | |
| 104 | + | |
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 15 | + | |
20 | 16 | | |
21 | 17 | | |
22 | | - | |
23 | 18 | | |
24 | 19 | | |
25 | 20 | | |
26 | 21 | | |
27 | 22 | | |
28 | 23 | | |
29 | 24 | | |
30 | | - | |
| 25 | + | |
31 | 26 | | |
32 | 27 | | |
33 | 28 | | |
| |||
38 | 33 | | |
39 | 34 | | |
40 | 35 | | |
| 36 | + | |
41 | 37 | | |
42 | 38 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 39 | | |
49 | | - | |
50 | 40 | | |
51 | 41 | | |
52 | 42 | | |
53 | 43 | | |
54 | 44 | | |
55 | 45 | | |
56 | | - | |
57 | 46 | | |
58 | 47 | | |
59 | 48 | | |
| |||
83 | 72 | | |
84 | 73 | | |
85 | 74 | | |
86 | | - | |
| 75 | + | |
87 | 76 | | |
88 | 77 | | |
89 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 25 | + | |
30 | 26 | | |
31 | 27 | | |
32 | | - | |
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
| |||
52 | 47 | | |
53 | 48 | | |
54 | 49 | | |
55 | | - | |
| 50 | + | |
56 | 51 | | |
57 | 52 | | |
58 | 53 | | |
| |||
308 | 303 | | |
309 | 304 | | |
310 | 305 | | |
| 306 | + | |
311 | 307 | | |
312 | 308 | | |
313 | 309 | | |
| |||
319 | 315 | | |
320 | 316 | | |
321 | 317 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | 318 | | |
328 | 319 | | |
329 | 320 | | |
330 | 321 | | |
331 | 322 | | |
332 | 323 | | |
333 | 324 | | |
334 | | - | |
335 | 325 | | |
336 | 326 | | |
337 | 327 | | |
| |||
342 | 332 | | |
343 | 333 | | |
344 | 334 | | |
345 | | - | |
346 | 335 | | |
347 | 336 | | |
348 | 337 | | |
| |||
396 | 385 | | |
397 | 386 | | |
398 | 387 | | |
399 | | - | |
| 388 | + | |
400 | 389 | | |
401 | 390 | | |
402 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 10 | + | |
15 | 11 | | |
16 | 12 | | |
17 | 13 | | |
18 | 14 | | |
19 | 15 | | |
20 | 16 | | |
21 | | - | |
22 | 17 | | |
23 | 18 | | |
24 | 19 | | |
| |||
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
36 | | - | |
| 31 | + | |
37 | 32 | | |
38 | 33 | | |
39 | 34 | | |
| |||
64 | 59 | | |
65 | 60 | | |
66 | 61 | | |
| 62 | + | |
67 | 63 | | |
68 | 64 | | |
69 | 65 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 66 | | |
76 | 67 | | |
77 | 68 | | |
78 | 69 | | |
79 | 70 | | |
80 | 71 | | |
81 | | - | |
82 | 72 | | |
83 | 73 | | |
84 | 74 | | |
| |||
89 | 79 | | |
90 | 80 | | |
91 | 81 | | |
92 | | - | |
93 | 82 | | |
94 | 83 | | |
95 | 84 | | |
| |||
123 | 112 | | |
124 | 113 | | |
125 | 114 | | |
126 | | - | |
| 115 | + | |
127 | 116 | | |
128 | 117 | | |
129 | 118 | | |
| |||
0 commit comments