@zjaaal/artemis 0.1.1 → 0.1.2
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/README.md +1 -0
- package/dist/help/help.d.ts +6 -1
- package/dist/help/help.js +10 -0
- package/dist/models.d.ts +2 -0
- package/dist/run/run.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -336,6 +336,7 @@ Global flags may be typed before or after the command name: `art --json math add
|
|
|
336
336
|
| `art <topic>` or `art <topic> help` | every command inside the topic |
|
|
337
337
|
| `art <command> --help` | the command's arguments, flags, defaults, choices, aliases and examples |
|
|
338
338
|
| `art help --json` | the manifest of every command, as data |
|
|
339
|
+
| `art help <topic> --json` | the manifest narrowed to one topic: same shape, only its commands |
|
|
339
340
|
| `art help <command> --json` | the manifest entry of one command |
|
|
340
341
|
|
|
341
342
|
### The JSON contract
|
package/dist/help/help.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommandHelpFn, CreateStyleFn, ManifestFn, RootHelpFn, TopicHelpFn, UsageFn } from '../models.js';
|
|
1
|
+
import type { CommandHelpFn, CreateStyleFn, ManifestFn, TopicManifestFn, RootHelpFn, TopicHelpFn, UsageFn } from '../models.js';
|
|
2
2
|
/** Color helpers; with `enabled` false they return the text untouched. */
|
|
3
3
|
export declare const createStyle: CreateStyleFn;
|
|
4
4
|
/** `art uve config set [url] [flags]` */
|
|
@@ -8,3 +8,8 @@ export declare const topicHelp: TopicHelpFn;
|
|
|
8
8
|
export declare const commandHelp: CommandHelpFn;
|
|
9
9
|
/** Everything help shows, as data: what an agent reads to know which commands exist and how to call them. */
|
|
10
10
|
export declare const manifest: ManifestFn;
|
|
11
|
+
/**
|
|
12
|
+
* The manifest of one topic: the topic and its sub-topics, and every command under it. It keeps the
|
|
13
|
+
* shape of the whole manifest, so a caller reads both the same way.
|
|
14
|
+
*/
|
|
15
|
+
export declare const topicManifest: TopicManifestFn;
|
package/dist/help/help.js
CHANGED
|
@@ -157,3 +157,13 @@ export const manifest = (bin, registry) => ({
|
|
|
157
157
|
commands: [...registry.commands.values()].map((entry) => describeCommand(bin, entry)),
|
|
158
158
|
globalFlags: describeFlags(GLOBAL_FLAGS)
|
|
159
159
|
});
|
|
160
|
+
const isWithin = (id, topicId) => id === topicId || id.startsWith(`${topicId} `);
|
|
161
|
+
/**
|
|
162
|
+
* The manifest of one topic: the topic and its sub-topics, and every command under it. It keeps the
|
|
163
|
+
* shape of the whole manifest, so a caller reads both the same way.
|
|
164
|
+
*/
|
|
165
|
+
export const topicManifest = (everything, topicId) => ({
|
|
166
|
+
...everything,
|
|
167
|
+
topics: everything.topics.filter((topic) => isWithin(topic.id, topicId)),
|
|
168
|
+
commands: everything.commands.filter((command) => isWithin(command.id, topicId))
|
|
169
|
+
});
|
package/dist/models.d.ts
CHANGED
|
@@ -288,6 +288,8 @@ export type Manifest = {
|
|
|
288
288
|
globalFlags: ManifestFlag[];
|
|
289
289
|
};
|
|
290
290
|
export type ManifestFn = (bin: string, registry: Registry) => Manifest;
|
|
291
|
+
/** The manifest narrowed to one topic: the topic and its sub-topics, and every command under it. Same shape. */
|
|
292
|
+
export type TopicManifestFn = (everything: Manifest, topicId: string) => Manifest;
|
|
291
293
|
/** Where output goes. A node `Writable`, such as `process.stdout`, fits. */
|
|
292
294
|
export type OutputSink = {
|
|
293
295
|
write: (chunk: string) => unknown;
|
package/dist/run/run.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createContext } from '../context/context.js';
|
|
|
2
2
|
import { EXIT_CODE, FLAG_PREFIX, HELP_WORD, ID_SEPARATOR } from '../constants.js';
|
|
3
3
|
import { discover } from '../discover/discover.js';
|
|
4
4
|
import { CommandError, UsageError, isUsageError } from '../errors/errors.js';
|
|
5
|
-
import { commandHelp, manifest, rootHelp, topicHelp, usage } from '../help/help.js';
|
|
5
|
+
import { commandHelp, manifest, rootHelp, topicHelp, topicManifest, usage } from '../help/help.js';
|
|
6
6
|
import { parse } from '../parse/parse.js';
|
|
7
7
|
import { reportError } from './report.js';
|
|
8
8
|
import { resolveWorld } from './world.js';
|
|
@@ -79,7 +79,10 @@ function helpFor(session, target) {
|
|
|
79
79
|
const { bin, registry, style } = session;
|
|
80
80
|
const everything = manifest(bin, registry);
|
|
81
81
|
if (target.kind === 'topic') {
|
|
82
|
-
return {
|
|
82
|
+
return {
|
|
83
|
+
text: topicHelp(bin, registry, target.topic, style),
|
|
84
|
+
data: topicManifest(everything, target.topic.id)
|
|
85
|
+
};
|
|
83
86
|
}
|
|
84
87
|
return {
|
|
85
88
|
text: commandHelp(bin, target.entry, style),
|
package/package.json
CHANGED