@lewishowles/cli-style 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +66 -10
- package/adapters/python/cli_style/__init__.py +73 -0
- package/adapters/python/cli_style/_wrappers.py +503 -0
- package/adapters/python/cli_style/core.py +136 -0
- package/adapters/python/pyproject.toml +15 -0
- package/adapters/swift/Package.swift +16 -0
- package/adapters/swift/Sources/CliStyle/CliStyle.swift +223 -0
- package/adapters/swift/Sources/CliStyle/Wrappers.swift +582 -0
- package/package.json +4 -2
- package/scripts/build-binary.sh +15 -3
- package/scripts/generate-adapters.js +413 -0
- package/scripts/package-binary.sh +4 -1
- package/src/catalogue/renderer-catalogue.js +958 -52
- package/src/cli/adapter-path-command.js +3 -3
- package/src/cli/render-command.js +6 -0
- package/src/gallery/render-gallery.js +80 -0
- package/src/index.js +3 -0
- package/src/patterns/audit-finding.js +4 -4
- package/src/patterns/command-result.js +2 -2
- package/src/patterns/diagnostic-report.js +6 -3
- package/src/patterns/helpers.js +11 -4
- package/src/patterns/next-step-block.js +2 -4
- package/src/patterns/task-summary.js +4 -4
- package/src/primitives/bullet-list.js +150 -0
- package/src/primitives/table.js +103 -22
- package/src/theme/bullets.js +41 -0
- package/adapters/python/cli_style.py +0 -384
- package/adapters/swift/CliStyle.swift +0 -482
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
// Generated by scripts/generate-adapters.js. Do not edit directly.
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
|
|
5
|
+
extension CliStyle {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Return agent-transcript output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
9
|
+
*/
|
|
10
|
+
public static func agentTranscript(
|
|
11
|
+
entries: [[String: Any]]? = nil,
|
|
12
|
+
title: String? = nil,
|
|
13
|
+
options: CliStyleOptions = .init()
|
|
14
|
+
) throws -> String {
|
|
15
|
+
var data: [String: Any] = [
|
|
16
|
+
"entries": entries ?? [],
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
if let title = title {
|
|
20
|
+
data["title"] = title
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return try render("agent-transcript", data: data, options: options)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Return audit-finding output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
28
|
+
*/
|
|
29
|
+
public static func auditFinding(
|
|
30
|
+
result: String,
|
|
31
|
+
finding: String,
|
|
32
|
+
location: String = "",
|
|
33
|
+
recommendation: String = "",
|
|
34
|
+
evidence: String = "",
|
|
35
|
+
reference: String = "",
|
|
36
|
+
options: CliStyleOptions = .init()
|
|
37
|
+
) throws -> String {
|
|
38
|
+
let data: [String: Any] = [
|
|
39
|
+
"result": result,
|
|
40
|
+
"finding": finding,
|
|
41
|
+
"location": location,
|
|
42
|
+
"recommendation": recommendation,
|
|
43
|
+
"evidence": evidence.isEmpty ? [] : [evidence],
|
|
44
|
+
"references": reference.isEmpty ? [] : [reference],
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
return try render("audit-finding", data: data, options: options)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Return bar-chart output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
52
|
+
*/
|
|
53
|
+
public static func barChart(
|
|
54
|
+
rows: [[String: Any]]? = nil,
|
|
55
|
+
barWidth: Int? = nil,
|
|
56
|
+
options: CliStyleOptions = .init()
|
|
57
|
+
) throws -> String {
|
|
58
|
+
var data: [String: Any] = [
|
|
59
|
+
"rows": rows ?? [],
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
if let barWidth = barWidth {
|
|
63
|
+
data["barWidth"] = barWidth
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return try render("bar-chart", data: data, options: options)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Return bullet-list output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
71
|
+
*/
|
|
72
|
+
public static func bulletList(
|
|
73
|
+
items: [[String: Any]],
|
|
74
|
+
options: CliStyleOptions = .init()
|
|
75
|
+
) throws -> String {
|
|
76
|
+
let data: [String: Any] = [
|
|
77
|
+
"items": items,
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
return try render("bullet-list", data: data, options: options)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Return chip output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
85
|
+
*/
|
|
86
|
+
public static func chip(
|
|
87
|
+
label: String,
|
|
88
|
+
tone: String = "neutral",
|
|
89
|
+
options: CliStyleOptions = .init()
|
|
90
|
+
) throws -> String {
|
|
91
|
+
let data: [String: Any] = [
|
|
92
|
+
"label": label,
|
|
93
|
+
"tone": tone,
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
return try render("chip", data: data, options: options)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Return command-result output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
101
|
+
*/
|
|
102
|
+
public static func commandResult(
|
|
103
|
+
result: String,
|
|
104
|
+
summary: String,
|
|
105
|
+
command: String = "",
|
|
106
|
+
exitCode: Int? = nil,
|
|
107
|
+
duration: String = "",
|
|
108
|
+
detail: String = "",
|
|
109
|
+
options: CliStyleOptions = .init()
|
|
110
|
+
) throws -> String {
|
|
111
|
+
var data: [String: Any] = [
|
|
112
|
+
"result": result,
|
|
113
|
+
"summary": summary,
|
|
114
|
+
"command": command,
|
|
115
|
+
"duration": duration,
|
|
116
|
+
"details": detail.isEmpty ? [] : [detail],
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
if let exitCode = exitCode {
|
|
120
|
+
data["exitCode"] = exitCode
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return try render("command-result", data: data, options: options)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Return compact-data-table output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
128
|
+
*/
|
|
129
|
+
public static func compactDataTable(
|
|
130
|
+
columns: [[String: Any]],
|
|
131
|
+
rows: [[String: Any]],
|
|
132
|
+
summary: String = "",
|
|
133
|
+
title: String? = nil,
|
|
134
|
+
options: CliStyleOptions = .init()
|
|
135
|
+
) throws -> String {
|
|
136
|
+
var data: [String: Any] = [
|
|
137
|
+
"columns": columns,
|
|
138
|
+
"rows": rows,
|
|
139
|
+
"summary": summary,
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
if let title = title {
|
|
143
|
+
data["title"] = title
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return try render("compact-data-table", data: data, options: options)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Return confirmation-result output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
151
|
+
*/
|
|
152
|
+
public static func confirmationResult(
|
|
153
|
+
state: String,
|
|
154
|
+
action: String,
|
|
155
|
+
item: String = "",
|
|
156
|
+
detail: String = "",
|
|
157
|
+
options: CliStyleOptions = .init()
|
|
158
|
+
) throws -> String {
|
|
159
|
+
let data: [String: Any] = [
|
|
160
|
+
"state": state,
|
|
161
|
+
"action": action,
|
|
162
|
+
"item": item,
|
|
163
|
+
"detail": detail,
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
return try render("confirmation-result", data: data, options: options)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Return diagnostic-report output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
171
|
+
*/
|
|
172
|
+
public static func diagnosticReport(
|
|
173
|
+
title: String? = nil,
|
|
174
|
+
checks: [[String: Any]]? = nil,
|
|
175
|
+
findings: [[String: Any]]? = nil,
|
|
176
|
+
skippedChecks: [[String: Any]]? = nil,
|
|
177
|
+
nextActions: [String]? = nil,
|
|
178
|
+
options: CliStyleOptions = .init()
|
|
179
|
+
) throws -> String {
|
|
180
|
+
var data: [String: Any] = [
|
|
181
|
+
"checks": checks ?? [],
|
|
182
|
+
"findings": findings ?? [],
|
|
183
|
+
"skippedChecks": skippedChecks ?? [],
|
|
184
|
+
"nextActions": nextActions ?? [],
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
if let title = title {
|
|
188
|
+
data["title"] = title
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return try render("diagnostic-report", data: data, options: options)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Return diff-block output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
196
|
+
*/
|
|
197
|
+
public static func diffBlock(
|
|
198
|
+
lines: [[String: Any]]? = nil,
|
|
199
|
+
path: String = "",
|
|
200
|
+
title: String? = nil,
|
|
201
|
+
options: CliStyleOptions = .init()
|
|
202
|
+
) throws -> String {
|
|
203
|
+
var data: [String: Any] = [
|
|
204
|
+
"path": path,
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
if let lines = lines {
|
|
208
|
+
data["lines"] = lines
|
|
209
|
+
}
|
|
210
|
+
if let title = title {
|
|
211
|
+
data["title"] = title
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return try render("diff-block", data: data, options: options)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Return divider output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
219
|
+
*/
|
|
220
|
+
public static func divider(
|
|
221
|
+
label: String = "",
|
|
222
|
+
dividerWidth: Int? = nil,
|
|
223
|
+
dividerColour: String? = nil,
|
|
224
|
+
labelColour: String? = nil,
|
|
225
|
+
options: CliStyleOptions = .init()
|
|
226
|
+
) throws -> String {
|
|
227
|
+
var data: [String: Any] = [
|
|
228
|
+
"label": label,
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
if let dividerWidth = dividerWidth {
|
|
232
|
+
data["dividerWidth"] = dividerWidth
|
|
233
|
+
}
|
|
234
|
+
if let dividerColour = dividerColour {
|
|
235
|
+
data["dividerColour"] = dividerColour
|
|
236
|
+
}
|
|
237
|
+
if let labelColour = labelColour {
|
|
238
|
+
data["labelColour"] = labelColour
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return try render("divider", data: data, options: options)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Return empty-state output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
246
|
+
*/
|
|
247
|
+
public static func emptyState(
|
|
248
|
+
title: String = "No results",
|
|
249
|
+
detail: String = "",
|
|
250
|
+
options: CliStyleOptions = .init()
|
|
251
|
+
) throws -> String {
|
|
252
|
+
let data: [String: Any] = [
|
|
253
|
+
"title": title,
|
|
254
|
+
"detail": detail,
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
return try render("empty-state", data: data, options: options)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Return error-block output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
262
|
+
*/
|
|
263
|
+
public static func errorBlock(
|
|
264
|
+
title: String = "Failed",
|
|
265
|
+
lines: [String]? = nil,
|
|
266
|
+
options: CliStyleOptions = .init()
|
|
267
|
+
) throws -> String {
|
|
268
|
+
let data: [String: Any] = [
|
|
269
|
+
"title": title,
|
|
270
|
+
"lines": lines ?? [],
|
|
271
|
+
]
|
|
272
|
+
|
|
273
|
+
return try render("error-block", data: data, options: options)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Return hint output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
278
|
+
*/
|
|
279
|
+
public static func hint(
|
|
280
|
+
message: String,
|
|
281
|
+
options: CliStyleOptions = .init()
|
|
282
|
+
) throws -> String {
|
|
283
|
+
let data: [String: Any] = [
|
|
284
|
+
"message": message,
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
return try render("hint", data: data, options: options)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Return labelled-line output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
292
|
+
*/
|
|
293
|
+
public static func labelledLine(
|
|
294
|
+
label: String = "",
|
|
295
|
+
message: String = "",
|
|
296
|
+
icon: String = "",
|
|
297
|
+
tone: String = "info",
|
|
298
|
+
wrap: Bool = true,
|
|
299
|
+
wrapWidth: Int? = nil,
|
|
300
|
+
options: CliStyleOptions = .init()
|
|
301
|
+
) throws -> String {
|
|
302
|
+
var data: [String: Any] = [
|
|
303
|
+
"label": label,
|
|
304
|
+
"message": message,
|
|
305
|
+
"icon": icon,
|
|
306
|
+
"tone": tone,
|
|
307
|
+
"wrap": wrap,
|
|
308
|
+
]
|
|
309
|
+
|
|
310
|
+
if let wrapWidth = wrapWidth {
|
|
311
|
+
data["wrapWidth"] = wrapWidth
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return try render("labelled-line", data: data, options: options)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Return next-step-block output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
319
|
+
*/
|
|
320
|
+
public static func nextStepBlock(
|
|
321
|
+
nextStep: String,
|
|
322
|
+
reason: String = "",
|
|
323
|
+
command: String = "",
|
|
324
|
+
alternative: String = "",
|
|
325
|
+
options: CliStyleOptions = .init()
|
|
326
|
+
) throws -> String {
|
|
327
|
+
let data: [String: Any] = [
|
|
328
|
+
"next": nextStep,
|
|
329
|
+
"reason": reason,
|
|
330
|
+
"commands": command.isEmpty ? [] : [command],
|
|
331
|
+
"alternatives": alternative.isEmpty ? [] : [alternative],
|
|
332
|
+
]
|
|
333
|
+
|
|
334
|
+
return try render("next-step-block", data: data, options: options)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Return panel output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
339
|
+
*/
|
|
340
|
+
public static func panel(
|
|
341
|
+
lines: [String]? = nil,
|
|
342
|
+
title: String? = nil,
|
|
343
|
+
tone: String = "info",
|
|
344
|
+
panelWidth: Int? = nil,
|
|
345
|
+
options: CliStyleOptions = .init()
|
|
346
|
+
) throws -> String {
|
|
347
|
+
var data: [String: Any] = [
|
|
348
|
+
"lines": lines ?? [],
|
|
349
|
+
"tone": tone,
|
|
350
|
+
]
|
|
351
|
+
|
|
352
|
+
if let title = title {
|
|
353
|
+
data["title"] = title
|
|
354
|
+
}
|
|
355
|
+
if let panelWidth = panelWidth {
|
|
356
|
+
data["panelWidth"] = panelWidth
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return try render("panel", data: data, options: options)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Return progress-bar output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
364
|
+
*/
|
|
365
|
+
public static func progressBar(
|
|
366
|
+
max: Int = 100,
|
|
367
|
+
value: Int = 0,
|
|
368
|
+
barWidth: Int? = nil,
|
|
369
|
+
tone: String = "success",
|
|
370
|
+
options: CliStyleOptions = .init()
|
|
371
|
+
) throws -> String {
|
|
372
|
+
var data: [String: Any] = [
|
|
373
|
+
"max": max,
|
|
374
|
+
"value": value,
|
|
375
|
+
"tone": tone,
|
|
376
|
+
]
|
|
377
|
+
|
|
378
|
+
if let barWidth = barWidth {
|
|
379
|
+
data["barWidth"] = barWidth
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return try render("progress-bar", data: data, options: options)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Return row output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
387
|
+
*/
|
|
388
|
+
public static func row(
|
|
389
|
+
label: String,
|
|
390
|
+
value: String,
|
|
391
|
+
result: String = "",
|
|
392
|
+
labelWidth: Int? = nil,
|
|
393
|
+
labelColour: String? = nil,
|
|
394
|
+
valueColour: String? = nil,
|
|
395
|
+
separator: String? = nil,
|
|
396
|
+
options: CliStyleOptions = .init()
|
|
397
|
+
) throws -> String {
|
|
398
|
+
var data: [String: Any] = [
|
|
399
|
+
"label": label,
|
|
400
|
+
"value": value,
|
|
401
|
+
"result": result,
|
|
402
|
+
]
|
|
403
|
+
|
|
404
|
+
if let labelWidth = labelWidth {
|
|
405
|
+
data["labelWidth"] = labelWidth
|
|
406
|
+
}
|
|
407
|
+
if let labelColour = labelColour {
|
|
408
|
+
data["labelColour"] = labelColour
|
|
409
|
+
}
|
|
410
|
+
if let valueColour = valueColour {
|
|
411
|
+
data["valueColour"] = valueColour
|
|
412
|
+
}
|
|
413
|
+
if let separator = separator {
|
|
414
|
+
data["separator"] = separator
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return try render("row", data: data, options: options)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Return row-group output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
422
|
+
*/
|
|
423
|
+
public static func rowGroup(
|
|
424
|
+
rows: [[String: Any]],
|
|
425
|
+
labelWidth: Int? = nil,
|
|
426
|
+
options: CliStyleOptions = .init()
|
|
427
|
+
) throws -> String {
|
|
428
|
+
var data: [String: Any] = [
|
|
429
|
+
"rows": rows,
|
|
430
|
+
]
|
|
431
|
+
|
|
432
|
+
if let labelWidth = labelWidth {
|
|
433
|
+
data["labelWidth"] = labelWidth
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return try render("row-group", data: data, options: options)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Return sparkline output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
441
|
+
*/
|
|
442
|
+
public static func sparkline(
|
|
443
|
+
values: [Double]? = nil,
|
|
444
|
+
width: Int? = nil,
|
|
445
|
+
label: String? = nil,
|
|
446
|
+
tone: String = "success",
|
|
447
|
+
options: CliStyleOptions = .init()
|
|
448
|
+
) throws -> String {
|
|
449
|
+
var data: [String: Any] = [
|
|
450
|
+
"values": values ?? [],
|
|
451
|
+
"tone": tone,
|
|
452
|
+
]
|
|
453
|
+
|
|
454
|
+
if let width = width {
|
|
455
|
+
data["width"] = width
|
|
456
|
+
}
|
|
457
|
+
if let label = label {
|
|
458
|
+
data["label"] = label
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
return try render("sparkline", data: data, options: options)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Return span output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
466
|
+
*/
|
|
467
|
+
public static func span(
|
|
468
|
+
value: String,
|
|
469
|
+
tone: String = "info",
|
|
470
|
+
weight: String? = nil,
|
|
471
|
+
options: CliStyleOptions = .init()
|
|
472
|
+
) throws -> String {
|
|
473
|
+
var data: [String: Any] = [
|
|
474
|
+
"value": value,
|
|
475
|
+
"tone": tone,
|
|
476
|
+
]
|
|
477
|
+
|
|
478
|
+
if let weight = weight {
|
|
479
|
+
data["weight"] = weight
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return try render("span", data: data, options: options)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Return status output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
487
|
+
*/
|
|
488
|
+
public static func status(
|
|
489
|
+
type: String,
|
|
490
|
+
label: String = "",
|
|
491
|
+
detail: String = "",
|
|
492
|
+
options: CliStyleOptions = .init()
|
|
493
|
+
) throws -> String {
|
|
494
|
+
let data: [String: Any] = [
|
|
495
|
+
"type": type,
|
|
496
|
+
"label": label,
|
|
497
|
+
"detail": detail,
|
|
498
|
+
]
|
|
499
|
+
|
|
500
|
+
return try render("status", data: data, options: options)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Return step output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
505
|
+
*/
|
|
506
|
+
public static func step(
|
|
507
|
+
label: String = "",
|
|
508
|
+
state: String = "pending",
|
|
509
|
+
options: CliStyleOptions = .init()
|
|
510
|
+
) throws -> String {
|
|
511
|
+
let data: [String: Any] = [
|
|
512
|
+
"label": label,
|
|
513
|
+
"state": state,
|
|
514
|
+
]
|
|
515
|
+
|
|
516
|
+
return try render("step", data: data, options: options)
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Return step-progress output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
521
|
+
*/
|
|
522
|
+
public static func stepProgress(
|
|
523
|
+
current: Int = 0,
|
|
524
|
+
steps: [String]? = nil,
|
|
525
|
+
options: CliStyleOptions = .init()
|
|
526
|
+
) throws -> String {
|
|
527
|
+
let data: [String: Any] = [
|
|
528
|
+
"current": current,
|
|
529
|
+
"steps": steps ?? [],
|
|
530
|
+
]
|
|
531
|
+
|
|
532
|
+
return try render("step-progress", data: data, options: options)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Return table output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
537
|
+
*/
|
|
538
|
+
public static func table(
|
|
539
|
+
columns: [[String: Any]],
|
|
540
|
+
rows: [[String: Any]],
|
|
541
|
+
unicode: Bool? = nil,
|
|
542
|
+
width: Int? = nil,
|
|
543
|
+
options: CliStyleOptions = .init()
|
|
544
|
+
) throws -> String {
|
|
545
|
+
var data: [String: Any] = [
|
|
546
|
+
"columns": columns,
|
|
547
|
+
"rows": rows,
|
|
548
|
+
]
|
|
549
|
+
|
|
550
|
+
if let unicode = unicode {
|
|
551
|
+
data["unicode"] = unicode
|
|
552
|
+
}
|
|
553
|
+
if let width = width {
|
|
554
|
+
data["width"] = width
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return try render("table", data: data, options: options)
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Return task-summary output from the cli-style binary; `options` sets the profile, width, and binary.
|
|
562
|
+
*/
|
|
563
|
+
public static func taskSummary(
|
|
564
|
+
result: String,
|
|
565
|
+
task: String,
|
|
566
|
+
summary: String = "",
|
|
567
|
+
completed: String = "",
|
|
568
|
+
remaining: String = "",
|
|
569
|
+
options: CliStyleOptions = .init()
|
|
570
|
+
) throws -> String {
|
|
571
|
+
let data: [String: Any] = [
|
|
572
|
+
"result": result,
|
|
573
|
+
"task": task,
|
|
574
|
+
"summary": summary,
|
|
575
|
+
"completed": completed.isEmpty ? [] : [completed],
|
|
576
|
+
"remaining": remaining.isEmpty ? [] : [remaining],
|
|
577
|
+
]
|
|
578
|
+
|
|
579
|
+
return try render("task-summary", data: data, options: options)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lewishowles/cli-style",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Shared terminal output styles for Lewis Howles tools, diagnostics, and package CLIs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build:binary": "scripts/build-binary.sh",
|
|
32
|
-
"check": "vp check --fix",
|
|
32
|
+
"check": "vp check --fix && bun run check:adapters",
|
|
33
|
+
"check:adapters": "bun scripts/generate-adapters.js --check",
|
|
33
34
|
"cli-style:gallery": "bun ./bin/cli-style.js gallery",
|
|
35
|
+
"generate:adapters": "bun scripts/generate-adapters.js",
|
|
34
36
|
"package:binary": "scripts/package-binary.sh",
|
|
35
37
|
"prepare": "vp config --no-agent",
|
|
36
38
|
"smoke:binary": "./dist/bin/cli-style render status --plain < tests/fixtures/render/status-success.json",
|
package/scripts/build-binary.sh
CHANGED
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
# Release layout:
|
|
5
5
|
# dist/bin/cli-style
|
|
6
6
|
# dist/adapters/bash/cli-style.sh
|
|
7
|
-
# dist/adapters/python/cli_style
|
|
7
|
+
# dist/adapters/python/cli_style/
|
|
8
|
+
# dist/adapters/python/pyproject.toml
|
|
9
|
+
# dist/adapters/swift/Package.swift
|
|
10
|
+
# dist/adapters/swift/Sources/
|
|
8
11
|
|
|
9
12
|
set -euo pipefail
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
# Start from an empty adapters folder so files removed from adapters/ do not
|
|
15
|
+
# linger in the release from an earlier build.
|
|
16
|
+
rm -rf "dist/adapters"
|
|
17
|
+
mkdir -p "dist/bin" "dist/adapters/bash" "dist/adapters/python" "dist/adapters/swift"
|
|
12
18
|
|
|
13
19
|
build_args=(--compile ./bin/cli-style.js --outfile ./dist/bin/cli-style)
|
|
14
20
|
|
|
@@ -19,4 +25,10 @@ fi
|
|
|
19
25
|
bun build "${build_args[@]}"
|
|
20
26
|
|
|
21
27
|
cp adapters/bash/cli-style.sh dist/adapters/bash/cli-style.sh
|
|
22
|
-
|
|
28
|
+
|
|
29
|
+
# Copy the Python package without the __pycache__ folders Python leaves behind.
|
|
30
|
+
tar -C "adapters/python" \
|
|
31
|
+
--exclude="__pycache__" \
|
|
32
|
+
-cf - cli_style pyproject.toml | tar -C "dist/adapters/python" -xf -
|
|
33
|
+
|
|
34
|
+
cp -R adapters/swift/Package.swift adapters/swift/Sources dist/adapters/swift/
|