@forwardimpact/libcli 0.1.5 → 0.1.7
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/package.json +17 -2
- package/src/help.js +15 -0
package/package.json
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forwardimpact/libcli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "Agent-friendly CLIs: argument parsing, grep-friendly help output, JSON mode, and skill-doc links surfaced in `--help`.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"agent",
|
|
8
|
+
"arguments",
|
|
9
|
+
"help",
|
|
10
|
+
"grep"
|
|
11
|
+
],
|
|
12
|
+
"forwardimpact": {
|
|
13
|
+
"capability": "agent-capability",
|
|
14
|
+
"needs": [
|
|
15
|
+
"Parse CLI args and render help",
|
|
16
|
+
"Render colored tables and JSON output",
|
|
17
|
+
"Surface skill-doc links in CLI --help output"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
5
20
|
"license": "Apache-2.0",
|
|
6
21
|
"author": "D. Olsson <hi@senzilla.io>",
|
|
7
22
|
"type": "module",
|
package/src/help.js
CHANGED
|
@@ -83,6 +83,20 @@ export class HelpRenderer {
|
|
|
83
83
|
return this.#renderExamplesArray(definition.examples);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
#renderDocumentation(definition) {
|
|
87
|
+
if (!definition.documentation || definition.documentation.length === 0) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
const lines = [this.#sectionHeader("Documentation:")];
|
|
91
|
+
for (const entry of definition.documentation) {
|
|
92
|
+
lines.push(` ${entry.title}`);
|
|
93
|
+
lines.push(` ${entry.url}`);
|
|
94
|
+
if (entry.description) lines.push(` ${entry.description}`);
|
|
95
|
+
}
|
|
96
|
+
lines.push("");
|
|
97
|
+
return lines;
|
|
98
|
+
}
|
|
99
|
+
|
|
86
100
|
#renderHintLine(definition) {
|
|
87
101
|
if (!definition.commands || definition.commands.length === 0) return [];
|
|
88
102
|
return [
|
|
@@ -135,6 +149,7 @@ export class HelpRenderer {
|
|
|
135
149
|
...this.#renderCommands(definition),
|
|
136
150
|
...this.#renderOptionSection(definition.globalOptions, "Options:"),
|
|
137
151
|
...this.#renderExamples(definition),
|
|
152
|
+
...this.#renderDocumentation(definition),
|
|
138
153
|
...this.#renderHintLine(definition),
|
|
139
154
|
];
|
|
140
155
|
out.write(lines.join("\n"));
|