@lewishowles/cli-style 0.6.0 → 0.7.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 +12 -1
- package/README.md +62 -38
- package/adapters/bash/cli-style.sh +200 -0
- package/adapters/python/cli_style.py +215 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.7.0 - 2026-07-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added Python adapter convenience functions for scalar pattern usage: `command_result`, `audit_finding`, `task_summary`, `confirmation_result`, and `next_step_block`.
|
|
8
|
+
- Added Python adapter convenience functions for common primitives: `status`, `row`, `span`, `hint`, and `divider`.
|
|
9
|
+
- Added Bash adapter convenience functions for scalar pattern usage: `cli_style_command_result`, `cli_style_audit_finding`, `cli_style_task_summary`, `cli_style_confirmation_result`, and `cli_style_next_step_block`.
|
|
10
|
+
- Added Bash adapter helpers for JSON string arrays and integer/null fields, so pattern wrappers can safely pass single-item list fields and exit codes.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Extended the README renderer table with a Python helper column covering all 20 renderers, including convenience functions and `render()` fallbacks for aggregate patterns.
|
|
4
15
|
|
|
5
16
|
## 0.6.0 - 2026-07-03
|
|
6
17
|
|
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ Use renderer names from the tables below, for example `status`, `row`, `diagnost
|
|
|
84
84
|
|
|
85
85
|
### Bash
|
|
86
86
|
|
|
87
|
-
Source the Bash adapter, then use convenience helpers for common primitive renderers:
|
|
87
|
+
Source the Bash adapter, then use convenience helpers for common primitive and per-script pattern renderers:
|
|
88
88
|
|
|
89
89
|
```bash
|
|
90
90
|
source "$(cli-style adapter-path bash)"
|
|
@@ -98,6 +98,11 @@ cli_style_row "Bundle" "is 22.3 KB, above the 12.0 KB budget" failed --plain
|
|
|
98
98
|
command="$(cli_style_span "npm run docs:readme" info --plain)"
|
|
99
99
|
cli_style_hint "Run $command before release" --plain
|
|
100
100
|
cli_style_divider "Project setup" --plain
|
|
101
|
+
|
|
102
|
+
cli_style_command_result success "Build passed" "bun run test:unit" 0 "1.2s" "184 tests" --plain
|
|
103
|
+
cli_style_task_summary partial "Adopt cli-style" "Bash wrappers added" "Updated adapter" "Update scripts" --plain
|
|
104
|
+
cli_style_confirmation_result confirmed "Publish release" "v0.6.0" "Tag push starts npm publish" --plain
|
|
105
|
+
cli_style_next_step_block "Update helpers scripts" "Wrappers are now available" "scripts/setup.sh --check" "" --plain
|
|
101
106
|
```
|
|
102
107
|
|
|
103
108
|
The convenience functions build JSON internally, so callers do not need to escape quotes, backslashes, or paths by hand.
|
|
@@ -108,7 +113,7 @@ Set `CLI_STYLE_BIN` when `cli-style` is not on `PATH`:
|
|
|
108
113
|
CLI_STYLE_BIN="/path/to/cli-style" cli_style_status success "Build passed" "" --plain
|
|
109
114
|
```
|
|
110
115
|
|
|
111
|
-
Use `cli_style_render` for literal or prebuilt JSON, especially for
|
|
116
|
+
Use `cli_style_render` for literal or prebuilt JSON, especially for aggregate patterns or multi-item pattern fields:
|
|
112
117
|
|
|
113
118
|
```bash
|
|
114
119
|
cli_style_render diagnostic-report --profile diagnostic <<'JSON'
|
|
@@ -126,64 +131,71 @@ JSON
|
|
|
126
131
|
|
|
127
132
|
### Python
|
|
128
133
|
|
|
129
|
-
Add the adapter directory to `PYTHONPATH`, then import the generic `render()` helper:
|
|
134
|
+
Add the adapter directory to `PYTHONPATH`, then import the generic `render()` helper or convenience functions:
|
|
130
135
|
|
|
131
136
|
```bash
|
|
132
137
|
export PYTHONPATH="$(cli-style adapter-path python):$PYTHONPATH"
|
|
133
138
|
```
|
|
134
139
|
|
|
135
140
|
```python
|
|
136
|
-
from cli_style import
|
|
141
|
+
from cli_style import status, row, span, hint, divider
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
"status",
|
|
140
|
-
{
|
|
141
|
-
"type": "success",
|
|
142
|
-
"label": "Build passed",
|
|
143
|
-
"detail": "184 tests",
|
|
144
|
-
},
|
|
145
|
-
profile="diagnostic",
|
|
146
|
-
)
|
|
143
|
+
kwargs = {"binary": "./bin/cli-style.js", "plain": True}
|
|
147
144
|
|
|
148
|
-
print(
|
|
145
|
+
print(status("success", "Build passed", "184 tests", **kwargs))
|
|
146
|
+
print(row("Workspace", "/path/to/project", **kwargs))
|
|
147
|
+
print(row("Bundle", "over budget", "failed", **kwargs))
|
|
148
|
+
command = span("npm run docs:readme", "info", **kwargs)
|
|
149
|
+
print(hint(f"Run {command} before release", **kwargs))
|
|
150
|
+
print(divider("Project setup", **kwargs))
|
|
149
151
|
```
|
|
150
152
|
|
|
151
|
-
|
|
153
|
+
Convenience functions build the renderer payload internally, so callers pass plain Python strings without hand-building JSON.
|
|
154
|
+
|
|
155
|
+
Pass `binary=` when `cli-style` is not on `PATH`. The generic `render()` helper remains for aggregate patterns or multi-item fields:
|
|
152
156
|
|
|
153
157
|
```python
|
|
158
|
+
from cli_style import render
|
|
159
|
+
|
|
154
160
|
output = render(
|
|
155
|
-
"
|
|
161
|
+
"diagnostic-report",
|
|
156
162
|
{
|
|
157
|
-
"
|
|
158
|
-
"
|
|
163
|
+
"title": "Release checks",
|
|
164
|
+
"checks": [{"name": "README", "result": "success"}],
|
|
159
165
|
},
|
|
160
|
-
|
|
161
|
-
plain=True,
|
|
166
|
+
profile="diagnostic",
|
|
162
167
|
)
|
|
168
|
+
|
|
169
|
+
print(output)
|
|
163
170
|
```
|
|
164
171
|
|
|
165
172
|
## Available renderers
|
|
166
173
|
|
|
167
174
|
Renderer names are stable for `cli-style render`, `cli_style_render`, and Python `render()`. JavaScript uses camel-case function names.
|
|
168
175
|
|
|
169
|
-
| Renderer
|
|
170
|
-
|
|
|
171
|
-
| `status`
|
|
172
|
-
| `row`
|
|
173
|
-
| `span`
|
|
174
|
-
| `hint`
|
|
175
|
-
| `divider`
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `
|
|
184
|
-
| `
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
| Renderer | JavaScript | Bash helper | Python helper | Purpose |
|
|
177
|
+
| --------------------- | ------------------------------------- | ------------------------------------ | ---------------------------------- | --------------------------------------------------------------- |
|
|
178
|
+
| `status` | `status(resultType, detail, options)` | `cli_style_status type label detail` | `status(type, label, detail)` | Result line with symbol, label, and detail. |
|
|
179
|
+
| `row` | `row(label, value, options)` | `cli_style_row label value [result]` | `row(label, value, result)` | Aligned label/value row, optionally marked with a result state. |
|
|
180
|
+
| `span` | `span(value, tone, options)` | `cli_style_span value [tone]` | `span(value, tone)` | Inline colour or weight for a word, command, file, or value. |
|
|
181
|
+
| `hint` | `hint(message, options)` | `cli_style_hint message` | `hint(message)` | Informational hint line. |
|
|
182
|
+
| `divider` | `divider(options)` | `cli_style_divider label` | `divider(label)` | Section divider with an optional label. |
|
|
183
|
+
| `command-result` | `commandResult(options)` | `cli_style_command_result ...` | `command_result(...)` | Command execution outcome with exit code and duration. |
|
|
184
|
+
| `audit-finding` | `auditFinding(options)` | `cli_style_audit_finding ...` | `audit_finding(...)` | Structured audit finding with evidence and recommendation. |
|
|
185
|
+
| `task-summary` | `taskSummary(options)` | `cli_style_task_summary ...` | `task_summary(...)` | Task progress with completed and remaining items. |
|
|
186
|
+
| `confirmation-result` | `confirmationResult(options)` | `cli_style_confirmation_result ...` | `confirmation_result(...)` | Confirmation outcome with action and item. |
|
|
187
|
+
| `next-step-block` | `nextStepBlock(options)` | `cli_style_next_step_block ...` | `next_step_block(...)` | Next-step guidance with command and alternative. |
|
|
188
|
+
| `chip` | `chip(label, tone, options)` | Use `cli_style_render` | Use `render("chip", ...)` | Compact labelled state. |
|
|
189
|
+
| `panel` | `panel(options)` | Use `cli_style_render` | Use `render("panel", ...)` | Framed content block for grouped output. |
|
|
190
|
+
| `table` | `table(options)` | Use `cli_style_render` | Use `render("table", ...)` | Tabular records with narrow-width fallback. |
|
|
191
|
+
| `progress-bar` | `progressBar(options)` | Use `cli_style_render` | Use `render("progress-bar", ...)` | Single progress value with numeric text. |
|
|
192
|
+
| `bar-chart` | `barChart(options)` | Use `cli_style_render` | Use `render("bar-chart", ...)` | Multi-row bar chart. |
|
|
193
|
+
| `step` | `step(label, state, options)` | Use `cli_style_render` | Use `render("step", ...)` | One workflow step. |
|
|
194
|
+
| `step-progress` | `stepProgress(options)` | Use `cli_style_render` | Use `render("step-progress", ...)` | Numbered workflow steps. |
|
|
195
|
+
| `empty-state` | `emptyState(title, detail, options)` | Use `cli_style_render` | Use `render("empty-state", ...)` | Empty result message. |
|
|
196
|
+
| `error-block` | `errorBlock(title, lines, options)` | Use `cli_style_render` | Use `render("error-block", ...)` | Structured error block. |
|
|
197
|
+
|
|
198
|
+
Use `render("<renderer>", data, ...)` for aggregate patterns (`diagnostic-report`, `agent-transcript`, `compact-data-table`) or any renderer with multi-item fields.
|
|
187
199
|
|
|
188
200
|
## Primitive data shapes
|
|
189
201
|
|
|
@@ -277,6 +289,18 @@ Patterns are built-in composite renderers for common report shapes. They use the
|
|
|
277
289
|
|
|
278
290
|
For visual examples, run `cli-style gallery --section patterns`.
|
|
279
291
|
|
|
292
|
+
The Bash adapter also exposes scalar convenience wrappers for per-script usage:
|
|
293
|
+
|
|
294
|
+
| Bash helper | Renderer | Arguments before render flags |
|
|
295
|
+
| ------------------------------- | --------------------- | -------------------------------------------------------------------------- |
|
|
296
|
+
| `cli_style_command_result` | `command-result` | `result`, `summary`, `command`, `exit_code`, `duration`, `detail` |
|
|
297
|
+
| `cli_style_audit_finding` | `audit-finding` | `result`, `finding`, `location`, `recommendation`, `evidence`, `reference` |
|
|
298
|
+
| `cli_style_task_summary` | `task-summary` | `result`, `task`, `summary`, `completed`, `remaining` |
|
|
299
|
+
| `cli_style_confirmation_result` | `confirmation-result` | `state`, `action`, `item`, `detail` |
|
|
300
|
+
| `cli_style_next_step_block` | `next-step-block` | `next`, `reason`, `command`, `alternative` |
|
|
301
|
+
|
|
302
|
+
Pass an empty string for optional positional fields you want to skip. Use `cli_style_render` or `cli_style_render_json` for aggregate reports, tables, transcripts, and multi-item arrays.
|
|
303
|
+
|
|
280
304
|
### Pattern example
|
|
281
305
|
|
|
282
306
|
JavaScript:
|
|
@@ -41,6 +41,41 @@ cli_style_json_string() {
|
|
|
41
41
|
printf '"%s"' "$value"
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
# Escape Bash strings for a JSON string array.
|
|
45
|
+
#
|
|
46
|
+
# @param {string} ...
|
|
47
|
+
# String values to encode. Empty values are skipped.
|
|
48
|
+
cli_style_json_string_array() {
|
|
49
|
+
local item
|
|
50
|
+
local separator=""
|
|
51
|
+
|
|
52
|
+
printf '['
|
|
53
|
+
|
|
54
|
+
for item in "$@"; do
|
|
55
|
+
if [[ "$item" != "" ]]; then
|
|
56
|
+
printf '%s' "$separator"
|
|
57
|
+
cli_style_json_string "$item"
|
|
58
|
+
separator=","
|
|
59
|
+
fi
|
|
60
|
+
done
|
|
61
|
+
|
|
62
|
+
printf ']'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Render a Bash value as a JSON integer or null.
|
|
66
|
+
#
|
|
67
|
+
# @param {string} value
|
|
68
|
+
# Integer value to encode.
|
|
69
|
+
cli_style_json_integer_or_null() {
|
|
70
|
+
local value="${1:-}"
|
|
71
|
+
|
|
72
|
+
if [[ "$value" =~ ^-?[0-9]+$ ]]; then
|
|
73
|
+
printf '%s' "$value"
|
|
74
|
+
else
|
|
75
|
+
printf 'null'
|
|
76
|
+
fi
|
|
77
|
+
}
|
|
78
|
+
|
|
44
79
|
# Render a JSON object through the shared cli-style command.
|
|
45
80
|
#
|
|
46
81
|
# @param {string} renderer
|
|
@@ -208,3 +243,168 @@ cli_style_hint() {
|
|
|
208
243
|
|
|
209
244
|
cli_style_render_json hint "$json" "$@"
|
|
210
245
|
}
|
|
246
|
+
|
|
247
|
+
# Render a command result pattern from Bash string values.
|
|
248
|
+
#
|
|
249
|
+
# @param {string} result
|
|
250
|
+
# Result type such as success, failed, warning, or skipped.
|
|
251
|
+
# @param {string} summary
|
|
252
|
+
# Summary line.
|
|
253
|
+
# @param {string} command
|
|
254
|
+
# Optional command text.
|
|
255
|
+
# @param {string} exit_code
|
|
256
|
+
# Optional integer exit code.
|
|
257
|
+
# @param {string} duration
|
|
258
|
+
# Optional duration text.
|
|
259
|
+
# @param {string} detail
|
|
260
|
+
# Optional detail line.
|
|
261
|
+
# @param {string} ...
|
|
262
|
+
# Render flags passed through to `cli-style render`.
|
|
263
|
+
cli_style_command_result() {
|
|
264
|
+
local result="${1:-}"
|
|
265
|
+
local summary="${2:-}"
|
|
266
|
+
local command="${3:-}"
|
|
267
|
+
local exit_code="${4:-}"
|
|
268
|
+
local duration="${5:-}"
|
|
269
|
+
local detail="${6:-}"
|
|
270
|
+
local json
|
|
271
|
+
|
|
272
|
+
if (($# >= 6)); then
|
|
273
|
+
shift 6
|
|
274
|
+
else
|
|
275
|
+
set --
|
|
276
|
+
fi
|
|
277
|
+
|
|
278
|
+
json="{\"result\":$(cli_style_json_string "$result"),\"summary\":$(cli_style_json_string "$summary"),\"command\":$(cli_style_json_string "$command"),\"exitCode\":$(cli_style_json_integer_or_null "$exit_code"),\"duration\":$(cli_style_json_string "$duration"),\"details\":$(cli_style_json_string_array "$detail")}"
|
|
279
|
+
|
|
280
|
+
cli_style_render_json command-result "$json" "$@"
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
# Render an audit finding pattern from Bash string values.
|
|
284
|
+
#
|
|
285
|
+
# @param {string} result
|
|
286
|
+
# Result type such as success, failed, warning, or skipped.
|
|
287
|
+
# @param {string} finding
|
|
288
|
+
# Finding summary.
|
|
289
|
+
# @param {string} location
|
|
290
|
+
# Optional source location.
|
|
291
|
+
# @param {string} recommendation
|
|
292
|
+
# Optional recommendation text.
|
|
293
|
+
# @param {string} evidence
|
|
294
|
+
# Optional evidence line.
|
|
295
|
+
# @param {string} reference
|
|
296
|
+
# Optional reference line.
|
|
297
|
+
# @param {string} ...
|
|
298
|
+
# Render flags passed through to `cli-style render`.
|
|
299
|
+
cli_style_audit_finding() {
|
|
300
|
+
local result="${1:-}"
|
|
301
|
+
local finding="${2:-}"
|
|
302
|
+
local location="${3:-}"
|
|
303
|
+
local recommendation="${4:-}"
|
|
304
|
+
local evidence="${5:-}"
|
|
305
|
+
local reference="${6:-}"
|
|
306
|
+
local json
|
|
307
|
+
|
|
308
|
+
if (($# >= 6)); then
|
|
309
|
+
shift 6
|
|
310
|
+
else
|
|
311
|
+
set --
|
|
312
|
+
fi
|
|
313
|
+
|
|
314
|
+
json="{\"result\":$(cli_style_json_string "$result"),\"finding\":$(cli_style_json_string "$finding"),\"location\":$(cli_style_json_string "$location"),\"recommendation\":$(cli_style_json_string "$recommendation"),\"evidence\":$(cli_style_json_string_array "$evidence"),\"references\":$(cli_style_json_string_array "$reference")}"
|
|
315
|
+
|
|
316
|
+
cli_style_render_json audit-finding "$json" "$@"
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
# Render a task summary pattern from Bash string values.
|
|
320
|
+
#
|
|
321
|
+
# @param {string} result
|
|
322
|
+
# Result type such as success, failed, warning, or skipped.
|
|
323
|
+
# @param {string} task
|
|
324
|
+
# Task label.
|
|
325
|
+
# @param {string} summary
|
|
326
|
+
# Optional summary detail.
|
|
327
|
+
# @param {string} completed
|
|
328
|
+
# Optional completed item.
|
|
329
|
+
# @param {string} remaining
|
|
330
|
+
# Optional remaining item.
|
|
331
|
+
# @param {string} ...
|
|
332
|
+
# Render flags passed through to `cli-style render`.
|
|
333
|
+
cli_style_task_summary() {
|
|
334
|
+
local result="${1:-}"
|
|
335
|
+
local task="${2:-}"
|
|
336
|
+
local summary="${3:-}"
|
|
337
|
+
local completed="${4:-}"
|
|
338
|
+
local remaining="${5:-}"
|
|
339
|
+
local json
|
|
340
|
+
|
|
341
|
+
if (($# >= 5)); then
|
|
342
|
+
shift 5
|
|
343
|
+
else
|
|
344
|
+
set --
|
|
345
|
+
fi
|
|
346
|
+
|
|
347
|
+
json="{\"result\":$(cli_style_json_string "$result"),\"task\":$(cli_style_json_string "$task"),\"summary\":$(cli_style_json_string "$summary"),\"completed\":$(cli_style_json_string_array "$completed"),\"remaining\":$(cli_style_json_string_array "$remaining")}"
|
|
348
|
+
|
|
349
|
+
cli_style_render_json task-summary "$json" "$@"
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
# Render a confirmation result pattern from Bash string values.
|
|
353
|
+
#
|
|
354
|
+
# @param {string} state
|
|
355
|
+
# Confirmation state such as confirmed, cancelled, or skipped.
|
|
356
|
+
# @param {string} action
|
|
357
|
+
# Action label.
|
|
358
|
+
# @param {string} item
|
|
359
|
+
# Optional item label.
|
|
360
|
+
# @param {string} detail
|
|
361
|
+
# Optional detail text.
|
|
362
|
+
# @param {string} ...
|
|
363
|
+
# Render flags passed through to `cli-style render`.
|
|
364
|
+
cli_style_confirmation_result() {
|
|
365
|
+
local state="${1:-}"
|
|
366
|
+
local action="${2:-}"
|
|
367
|
+
local item="${3:-}"
|
|
368
|
+
local detail="${4:-}"
|
|
369
|
+
local json
|
|
370
|
+
|
|
371
|
+
if (($# >= 4)); then
|
|
372
|
+
shift 4
|
|
373
|
+
else
|
|
374
|
+
set --
|
|
375
|
+
fi
|
|
376
|
+
|
|
377
|
+
json="{\"state\":$(cli_style_json_string "$state"),\"action\":$(cli_style_json_string "$action"),\"item\":$(cli_style_json_string "$item"),\"detail\":$(cli_style_json_string "$detail")}"
|
|
378
|
+
|
|
379
|
+
cli_style_render_json confirmation-result "$json" "$@"
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
# Render a next-step block pattern from Bash string values.
|
|
383
|
+
#
|
|
384
|
+
# @param {string} next
|
|
385
|
+
# Next step text.
|
|
386
|
+
# @param {string} reason
|
|
387
|
+
# Optional reason text.
|
|
388
|
+
# @param {string} command
|
|
389
|
+
# Optional command line.
|
|
390
|
+
# @param {string} alternative
|
|
391
|
+
# Optional alternative line.
|
|
392
|
+
# @param {string} ...
|
|
393
|
+
# Render flags passed through to `cli-style render`.
|
|
394
|
+
cli_style_next_step_block() {
|
|
395
|
+
local next="${1:-}"
|
|
396
|
+
local reason="${2:-}"
|
|
397
|
+
local command="${3:-}"
|
|
398
|
+
local alternative="${4:-}"
|
|
399
|
+
local json
|
|
400
|
+
|
|
401
|
+
if (($# >= 4)); then
|
|
402
|
+
shift 4
|
|
403
|
+
else
|
|
404
|
+
set --
|
|
405
|
+
fi
|
|
406
|
+
|
|
407
|
+
json="{\"next\":$(cli_style_json_string "$next"),\"reason\":$(cli_style_json_string "$reason"),\"commands\":$(cli_style_json_string_array "$command"),\"alternatives\":$(cli_style_json_string_array "$alternative")}"
|
|
408
|
+
|
|
409
|
+
cli_style_render_json next-step-block "$json" "$@"
|
|
410
|
+
}
|
|
@@ -83,6 +83,221 @@ def render(
|
|
|
83
83
|
return result.stdout.rstrip("\n")
|
|
84
84
|
|
|
85
85
|
|
|
86
|
+
# Render a result status line from Python values.
|
|
87
|
+
#
|
|
88
|
+
# @param {str} type
|
|
89
|
+
# Result type such as success, failed, warning, or skipped.
|
|
90
|
+
# @param {str} label
|
|
91
|
+
# Status label.
|
|
92
|
+
# @param {str} detail
|
|
93
|
+
# Optional detail text.
|
|
94
|
+
def status(
|
|
95
|
+
type: str,
|
|
96
|
+
label: str = "",
|
|
97
|
+
detail: str = "",
|
|
98
|
+
**kwargs: Any,
|
|
99
|
+
) -> str:
|
|
100
|
+
return render("status", {"type": type, "label": label, "detail": detail}, **kwargs)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# Render a labelled value row from Python values.
|
|
104
|
+
#
|
|
105
|
+
# @param {str} label
|
|
106
|
+
# Row label.
|
|
107
|
+
# @param {str} value
|
|
108
|
+
# Row value.
|
|
109
|
+
# @param {str} result
|
|
110
|
+
# Optional result type for a symbol and tone.
|
|
111
|
+
def row(
|
|
112
|
+
label: str,
|
|
113
|
+
value: str,
|
|
114
|
+
result: str = "",
|
|
115
|
+
**kwargs: Any,
|
|
116
|
+
) -> str:
|
|
117
|
+
return render("row", {"label": label, "value": value, "result": result}, **kwargs)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# Render an inline span from Python values.
|
|
121
|
+
#
|
|
122
|
+
# @param {str} value
|
|
123
|
+
# Span text.
|
|
124
|
+
# @param {str} tone
|
|
125
|
+
# Optional colour tone, defaulting to info.
|
|
126
|
+
def span(
|
|
127
|
+
value: str,
|
|
128
|
+
tone: str = "info",
|
|
129
|
+
**kwargs: Any,
|
|
130
|
+
) -> str:
|
|
131
|
+
return render("span", {"value": value, "tone": tone}, **kwargs)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# Render a divider from a Python value.
|
|
135
|
+
#
|
|
136
|
+
# @param {str} label
|
|
137
|
+
# Optional divider label.
|
|
138
|
+
def divider(
|
|
139
|
+
label: str = "",
|
|
140
|
+
**kwargs: Any,
|
|
141
|
+
) -> str:
|
|
142
|
+
return render("divider", {"label": label}, **kwargs)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Render a hint from a Python value.
|
|
146
|
+
#
|
|
147
|
+
# @param {str} message
|
|
148
|
+
# Hint message.
|
|
149
|
+
def hint(
|
|
150
|
+
message: str,
|
|
151
|
+
**kwargs: Any,
|
|
152
|
+
) -> str:
|
|
153
|
+
return render("hint", {"message": message}, **kwargs)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# Render a command result pattern from Python values.
|
|
157
|
+
#
|
|
158
|
+
# @param {str} result
|
|
159
|
+
# Result type such as success, failed, warning, or skipped.
|
|
160
|
+
# @param {str} summary
|
|
161
|
+
# Summary line.
|
|
162
|
+
# @param {str} command
|
|
163
|
+
# Optional command text.
|
|
164
|
+
# @param {int|None} exit_code
|
|
165
|
+
# Optional integer exit code.
|
|
166
|
+
# @param {str} duration
|
|
167
|
+
# Optional duration text.
|
|
168
|
+
# @param {str} detail
|
|
169
|
+
# Optional detail line.
|
|
170
|
+
def command_result(
|
|
171
|
+
result: str,
|
|
172
|
+
summary: str,
|
|
173
|
+
command: str = "",
|
|
174
|
+
exit_code: int | None = None,
|
|
175
|
+
duration: str = "",
|
|
176
|
+
detail: str = "",
|
|
177
|
+
**kwargs: Any,
|
|
178
|
+
) -> str:
|
|
179
|
+
return render("command-result", {
|
|
180
|
+
"result": result,
|
|
181
|
+
"summary": summary,
|
|
182
|
+
"command": command,
|
|
183
|
+
"exitCode": exit_code,
|
|
184
|
+
"duration": duration,
|
|
185
|
+
"details": [detail] if detail else [],
|
|
186
|
+
}, **kwargs)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# Render an audit finding pattern from Python values.
|
|
190
|
+
#
|
|
191
|
+
# @param {str} result
|
|
192
|
+
# Result type such as success, failed, warning, or skipped.
|
|
193
|
+
# @param {str} finding
|
|
194
|
+
# Finding summary.
|
|
195
|
+
# @param {str} location
|
|
196
|
+
# Optional source location.
|
|
197
|
+
# @param {str} recommendation
|
|
198
|
+
# Optional recommendation text.
|
|
199
|
+
# @param {str} evidence
|
|
200
|
+
# Optional evidence line.
|
|
201
|
+
# @param {str} reference
|
|
202
|
+
# Optional reference line.
|
|
203
|
+
def audit_finding(
|
|
204
|
+
result: str,
|
|
205
|
+
finding: str,
|
|
206
|
+
location: str = "",
|
|
207
|
+
recommendation: str = "",
|
|
208
|
+
evidence: str = "",
|
|
209
|
+
reference: str = "",
|
|
210
|
+
**kwargs: Any,
|
|
211
|
+
) -> str:
|
|
212
|
+
return render("audit-finding", {
|
|
213
|
+
"result": result,
|
|
214
|
+
"finding": finding,
|
|
215
|
+
"location": location,
|
|
216
|
+
"recommendation": recommendation,
|
|
217
|
+
"evidence": [evidence] if evidence else [],
|
|
218
|
+
"references": [reference] if reference else [],
|
|
219
|
+
}, **kwargs)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
# Render a task summary pattern from Python values.
|
|
223
|
+
#
|
|
224
|
+
# @param {str} result
|
|
225
|
+
# Result type such as success, failed, warning, or skipped.
|
|
226
|
+
# @param {str} task
|
|
227
|
+
# Task label.
|
|
228
|
+
# @param {str} summary
|
|
229
|
+
# Optional summary detail.
|
|
230
|
+
# @param {str} completed
|
|
231
|
+
# Optional completed item.
|
|
232
|
+
# @param {str} remaining
|
|
233
|
+
# Optional remaining item.
|
|
234
|
+
def task_summary(
|
|
235
|
+
result: str,
|
|
236
|
+
task: str,
|
|
237
|
+
summary: str = "",
|
|
238
|
+
completed: str = "",
|
|
239
|
+
remaining: str = "",
|
|
240
|
+
**kwargs: Any,
|
|
241
|
+
) -> str:
|
|
242
|
+
return render("task-summary", {
|
|
243
|
+
"result": result,
|
|
244
|
+
"task": task,
|
|
245
|
+
"summary": summary,
|
|
246
|
+
"completed": [completed] if completed else [],
|
|
247
|
+
"remaining": [remaining] if remaining else [],
|
|
248
|
+
}, **kwargs)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
# Render a confirmation result pattern from Python values.
|
|
252
|
+
#
|
|
253
|
+
# @param {str} state
|
|
254
|
+
# Confirmation state such as confirmed, cancelled, or skipped.
|
|
255
|
+
# @param {str} action
|
|
256
|
+
# Action label.
|
|
257
|
+
# @param {str} item
|
|
258
|
+
# Optional item label.
|
|
259
|
+
# @param {str} detail
|
|
260
|
+
# Optional detail text.
|
|
261
|
+
def confirmation_result(
|
|
262
|
+
state: str,
|
|
263
|
+
action: str,
|
|
264
|
+
item: str = "",
|
|
265
|
+
detail: str = "",
|
|
266
|
+
**kwargs: Any,
|
|
267
|
+
) -> str:
|
|
268
|
+
return render("confirmation-result", {
|
|
269
|
+
"state": state,
|
|
270
|
+
"action": action,
|
|
271
|
+
"item": item,
|
|
272
|
+
"detail": detail,
|
|
273
|
+
}, **kwargs)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
# Render a next-step block pattern from Python values.
|
|
277
|
+
#
|
|
278
|
+
# @param {str} next_step
|
|
279
|
+
# Next step text.
|
|
280
|
+
# @param {str} reason
|
|
281
|
+
# Optional reason text.
|
|
282
|
+
# @param {str} command
|
|
283
|
+
# Optional command line.
|
|
284
|
+
# @param {str} alternative
|
|
285
|
+
# Optional alternative line.
|
|
286
|
+
def next_step_block(
|
|
287
|
+
next_step: str,
|
|
288
|
+
reason: str = "",
|
|
289
|
+
command: str = "",
|
|
290
|
+
alternative: str = "",
|
|
291
|
+
**kwargs: Any,
|
|
292
|
+
) -> str:
|
|
293
|
+
return render("next-step-block", {
|
|
294
|
+
"next": next_step,
|
|
295
|
+
"reason": reason,
|
|
296
|
+
"commands": [command] if command else [],
|
|
297
|
+
"alternatives": [alternative] if alternative else [],
|
|
298
|
+
}, **kwargs)
|
|
299
|
+
|
|
300
|
+
|
|
86
301
|
# Resolve a command name or executable path for subprocess use.
|
|
87
302
|
#
|
|
88
303
|
# @param {str} binary
|