@flowscripter/example-cli 3.1.2 → 3.2.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/bun.lock
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
"": {
|
|
6
6
|
"name": "@flowscripter/example-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@flowscripter/dynamic-cli-framework": "^9.
|
|
8
|
+
"@flowscripter/dynamic-cli-framework": "^9.1.1",
|
|
9
9
|
"@flowscripter/dynamic-cli-framework-api": "^5.0.0",
|
|
10
10
|
"@flowscripter/dynamic-plugin-framework": "2.2.19",
|
|
11
|
+
"highlight.js": "^11.12.0",
|
|
11
12
|
"prettier": "^3.9.9",
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
},
|
|
23
24
|
},
|
|
24
25
|
"packages": {
|
|
25
|
-
"@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@9.
|
|
26
|
+
"@flowscripter/dynamic-cli-framework": ["@flowscripter/dynamic-cli-framework@9.1.1", "", { "dependencies": { "@flowscripter/dynamic-cli-framework-api": "^5.0.0", "@flowscripter/dynamic-plugin-framework": "^2.2.16", "emphasize": "^7.0.0", "fastest-levenshtein": "^1.0.16", "figlet": "^1.12.0", "highlight.js": "^11.12.0", "prettier": "^3.9.9", "semver": "^7.8.5", "supports-color": "^11.0.0", "supports-terminal-graphics": "^0.1.0" }, "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-lYUVz/fidMpExyzO9PJcZy4UI2/+qyMnnJLUtkT9oJhPSXEMC6+1ZVNJTUZDgFFAzxp4jegn/apuIqfwDDxMXg=="],
|
|
26
27
|
|
|
27
28
|
"@flowscripter/dynamic-cli-framework-api": ["@flowscripter/dynamic-cli-framework-api@5.0.0", "", { "peerDependencies": { "typescript": "^7.0.2" } }, "sha512-mF2V1Np+MKSQqeXGJO8WWT2dNiVlAKg1gFrf+lPriWBXLZFyv9JU44gDYtCMfenQuoaHMb3IgOwIfVeBclvYhQ=="],
|
|
28
29
|
|
|
@@ -19,7 +19,7 @@ Feature: Executable
|
|
|
19
19
|
And the executable should have output "--- Data Dump ---"
|
|
20
20
|
And the executable should have output "--- Pretty Printing: JSON (built-in syntax) ---"
|
|
21
21
|
And the executable should have output "--- Pretty Printing: YAML (added syntax) ---"
|
|
22
|
-
And the executable should have output "
|
|
22
|
+
And the executable should have output "nested:"
|
|
23
23
|
|
|
24
24
|
Scenario: Argument parsing demo
|
|
25
25
|
When the executable is launched with "demo:arg-parsing true 1 hello"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/example-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Simple example CLI using https://github.com/flowscripter/dynamic-cli-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@flowscripter/dynamic-cli-framework": "^9.
|
|
27
|
+
"@flowscripter/dynamic-cli-framework": "^9.1.1",
|
|
28
28
|
"@flowscripter/dynamic-cli-framework-api": "^5.0.0",
|
|
29
29
|
"@flowscripter/dynamic-plugin-framework": "2.2.19",
|
|
30
|
+
"highlight.js": "^11.12.0",
|
|
30
31
|
"prettier": "^3.9.9"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
package/src/commands/printing.ts
CHANGED
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
type PrinterService,
|
|
15
15
|
ProgressStyle,
|
|
16
16
|
SpinnerStyle,
|
|
17
|
+
SYNTAX_HIGHLIGHTER_SERVICE_ID,
|
|
18
|
+
type SyntaxHighlighterService,
|
|
17
19
|
type SubCommand,
|
|
18
20
|
Table,
|
|
19
21
|
TABLE_GENERATOR_SERVICE_ID,
|
|
@@ -23,6 +25,7 @@ import {
|
|
|
23
25
|
type TreePrinterService,
|
|
24
26
|
} from "@flowscripter/dynamic-cli-framework";
|
|
25
27
|
import { Buffer } from "node:buffer";
|
|
28
|
+
import highlightYaml from "highlight.js/lib/languages/yaml";
|
|
26
29
|
import * as yaml from "prettier/plugins/yaml";
|
|
27
30
|
|
|
28
31
|
async function sleep(seconds: number): Promise<void> {
|
|
@@ -51,6 +54,9 @@ const printing: SubCommand = {
|
|
|
51
54
|
const prettyPrinterService = context.getServiceById(
|
|
52
55
|
PRETTY_PRINTER_SERVICE_ID,
|
|
53
56
|
) as PrettyPrinterService;
|
|
57
|
+
const syntaxHighlighterService = context.getServiceById(
|
|
58
|
+
SYNTAX_HIGHLIGHTER_SERVICE_ID,
|
|
59
|
+
) as SyntaxHighlighterService;
|
|
54
60
|
|
|
55
61
|
// --- Basic Printer ---
|
|
56
62
|
await printerService.print("--- Basic Printer ---\n");
|
|
@@ -204,16 +210,26 @@ const printing: SubCommand = {
|
|
|
204
210
|
// --- Pretty Printing: JSON (built-in syntax) ---
|
|
205
211
|
await printerService.print("--- Pretty Printing: JSON (built-in syntax) ---\n");
|
|
206
212
|
const json = '{"name":"example-cli","tags":["cli","demo"],"nested":{"enabled":true,"count":3}}';
|
|
207
|
-
await printerService.print(
|
|
213
|
+
await printerService.print(
|
|
214
|
+
syntaxHighlighterService.highlight(await prettyPrinterService.prettify(json, "json"), "json"),
|
|
215
|
+
);
|
|
208
216
|
|
|
209
217
|
// --- Pretty Printing: YAML (added syntax) ---
|
|
210
218
|
await printerService.print("--- Pretty Printing: YAML (added syntax) ---\n");
|
|
211
219
|
if (!(await prettyPrinterService.getRegisteredSyntaxes()).includes("yaml")) {
|
|
212
220
|
await prettyPrinterService.registerSyntax("yaml", yaml);
|
|
213
221
|
}
|
|
222
|
+
if (!syntaxHighlighterService.getRegisteredSyntaxes().includes("yaml")) {
|
|
223
|
+
syntaxHighlighterService.registerSyntax("yaml", highlightYaml);
|
|
224
|
+
}
|
|
214
225
|
const yamlText =
|
|
215
226
|
"name: example-cli\ntags: [cli, demo]\nnested: {enabled: true, count: 3}\n";
|
|
216
|
-
await printerService.print(
|
|
227
|
+
await printerService.print(
|
|
228
|
+
syntaxHighlighterService.highlight(
|
|
229
|
+
await prettyPrinterService.prettify(yamlText, "yaml"),
|
|
230
|
+
"yaml",
|
|
231
|
+
),
|
|
232
|
+
);
|
|
217
233
|
},
|
|
218
234
|
};
|
|
219
235
|
|