@johannes.latzel/terminal 0.1.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.
Files changed (67) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +35 -0
  3. package/dist/command-arguments.d.ts +120 -0
  4. package/dist/command-arguments.d.ts.map +1 -0
  5. package/dist/command-arguments.js +155 -0
  6. package/dist/command-arguments.js.map +1 -0
  7. package/dist/command-factory.d.ts +17 -0
  8. package/dist/command-factory.d.ts.map +1 -0
  9. package/dist/command-factory.js +43 -0
  10. package/dist/command-factory.js.map +1 -0
  11. package/dist/command-tree.d.ts +40 -0
  12. package/dist/command-tree.d.ts.map +1 -0
  13. package/dist/command-tree.js +77 -0
  14. package/dist/command-tree.js.map +1 -0
  15. package/dist/commands/clear.d.ts +10 -0
  16. package/dist/commands/clear.d.ts.map +1 -0
  17. package/dist/commands/clear.js +13 -0
  18. package/dist/commands/clear.js.map +1 -0
  19. package/dist/commands/exit.d.ts +10 -0
  20. package/dist/commands/exit.d.ts.map +1 -0
  21. package/dist/commands/exit.js +13 -0
  22. package/dist/commands/exit.js.map +1 -0
  23. package/dist/commands/help.d.ts +40 -0
  24. package/dist/commands/help.d.ts.map +1 -0
  25. package/dist/commands/help.js +136 -0
  26. package/dist/commands/help.js.map +1 -0
  27. package/dist/completion/completer.d.ts +22 -0
  28. package/dist/completion/completer.d.ts.map +1 -0
  29. package/dist/completion/completer.js +55 -0
  30. package/dist/completion/completer.js.map +1 -0
  31. package/dist/errors.d.ts +18 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +28 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/hook.d.ts +11 -0
  36. package/dist/hook.d.ts.map +1 -0
  37. package/dist/hook.js +16 -0
  38. package/dist/hook.js.map +1 -0
  39. package/dist/hooks.d.ts +21 -0
  40. package/dist/hooks.d.ts.map +1 -0
  41. package/dist/hooks.js +17 -0
  42. package/dist/hooks.js.map +1 -0
  43. package/dist/index.d.ts +10 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +8 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/input/args-parser.d.ts +22 -0
  48. package/dist/input/args-parser.d.ts.map +1 -0
  49. package/dist/input/args-parser.js +52 -0
  50. package/dist/input/args-parser.js.map +1 -0
  51. package/dist/input/parser.d.ts +14 -0
  52. package/dist/input/parser.d.ts.map +1 -0
  53. package/dist/input/parser.js +65 -0
  54. package/dist/input/parser.js.map +1 -0
  55. package/dist/terminal-hook-builder.d.ts +42 -0
  56. package/dist/terminal-hook-builder.d.ts.map +1 -0
  57. package/dist/terminal-hook-builder.js +48 -0
  58. package/dist/terminal-hook-builder.js.map +1 -0
  59. package/dist/terminal.d.ts +86 -0
  60. package/dist/terminal.d.ts.map +1 -0
  61. package/dist/terminal.js +274 -0
  62. package/dist/terminal.js.map +1 -0
  63. package/dist/types.d.ts +80 -0
  64. package/dist/types.d.ts.map +1 -0
  65. package/dist/types.js +85 -0
  66. package/dist/types.js.map +1 -0
  67. package/package.json +82 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 Johannes B. Latzel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Terminal
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
+ [![NPM](https://nodei.co/npm/@johannes.latzel/terminal.svg?style=shields&data=n,v,u,d,s)](https://www.npmjs.com/package/@johannes.latzel/terminal)
5
+ [![version](https://img.shields.io/github/package-json/v/johanneslatzel/terminal)](https://github.com/johanneslatzel/terminal/releases)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-6.0-blue)](https://www.typescriptlang.org/)
7
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](https://github.com/johanneslatzel/terminal/pulls)
8
+ [![Feedback Welcome](https://img.shields.io/badge/feedback-welcome-brightgreen)](https://github.com/johanneslatzel/terminal/discussions)
9
+ [![codecov](https://codecov.io/gh/johanneslatzel/terminal/graph/badge.svg)](https://codecov.io/gh/johanneslatzel/terminal)
10
+ [![CI](https://github.com/johanneslatzel/terminal/actions/workflows/ci.yml/badge.svg)](https://github.com/johanneslatzel/terminal/actions/workflows/ci.yml)
11
+ [![Socket Badge](https://badge.socket.dev/npm/package/@johannes.latzel/terminal/latest)](https://badge.socket.dev/npm/package/@johannes.latzel/terminal/latest)
12
+
13
+ Tree-structured TypeScript terminal/shell engine with automatic help, tab completion, `--flag` argument parsing, interactive prompting for missing required arguments, and a lifecycle hook system.
14
+
15
+ ## Prerequisites
16
+
17
+ - Node.js >= 18
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install @johannes.latzel/terminal
23
+ ```
24
+
25
+ ## Documentation
26
+
27
+ Full documentation at **[johanneslatzel.github.io/terminal/](https://johanneslatzel.github.io/terminal/)**
28
+
29
+ ## License
30
+
31
+ MIT — see [`LICENSE`](LICENSE).
32
+
33
+ ## Contributing
34
+
35
+ Issues and PRs welcome at [github.com/johanneslatzel/terminal](https://github.com/johanneslatzel/terminal).
@@ -0,0 +1,120 @@
1
+ import * as readline from 'node:readline';
2
+ import type { z } from 'zod';
3
+ /** Describes a single command-line argument (`--name value`). */
4
+ export interface CommandArgumentDefinition {
5
+ /** Argument name (without `--` prefix). */
6
+ name: string;
7
+ /** Human-readable description shown in help output. */
8
+ description?: string;
9
+ /** Whether the argument must always be provided. */
10
+ required?: boolean;
11
+ /** Zod schema describing the argument's expected type and constraints. */
12
+ schema: z.ZodType;
13
+ /** 0-based index for positional (bare token) arguments. */
14
+ position?: number;
15
+ }
16
+ /**
17
+ * Wraps a parsed argument record (`--name value` pairs) and provides
18
+ * typed accessors that validate and coerce values via the argument's
19
+ * {@link CommandArgumentDefinition} zod schema. When an argument is
20
+ * missing and a readline interface is available, the accessor prompts
21
+ * the user interactively.
22
+ *
23
+ * Every `require*` accessor requires a matching
24
+ * {@link CommandArgumentDefinition} to exist for the requested name.
25
+ * If no definition is found, an {@link InvalidArgumentsError} is thrown.
26
+ *
27
+ * ## Choosing an accessor
28
+ *
29
+ * | Accessor | When to use | Schema examples |
30
+ * |---|---|---|
31
+ * | `require<T>(name)` | Value arg that must be present (or prompted). The Zod schema handles all parsing. | `z.coerce.number()`, `z.string().min(1)`, `z.enum([...])` |
32
+ * | `flag(name)` | CLI flag with `--flag` / `--flag false` semantics. Absent → `false`. | `z.boolean()`, `z.literal(true)` |
33
+ *
34
+ * Don't use `z.coerce.boolean()` or `z.boolean({ coerce: true })` in schemas —
35
+ * Zod 4's boolean coercion uses `Boolean()` which turns `"false"` into `true`.
36
+ * Always use `flag(name)` to read boolean arguments instead.
37
+ */
38
+ export declare class CommandArguments {
39
+ private record;
40
+ private rl;
41
+ private argDefs?;
42
+ /**
43
+ * @param record - Parsed `--name value` pairs.
44
+ * @param rl - Readline interface for interactive prompting, or `null`
45
+ * to disable prompting and throw on missing args.
46
+ * @param argDefs - Optional argument definitions used for schema-based
47
+ * validation. Looked up by name per accessor call.
48
+ */
49
+ constructor(record: Record<string, string>, rl: readline.Interface | null, argDefs?: CommandArgumentDefinition[] | undefined);
50
+ /**
51
+ * Check whether an argument was provided on the command line.
52
+ * @param name - Argument name (without `--` prefix).
53
+ */
54
+ has(name: string): boolean;
55
+ /**
56
+ * Return the raw string value of an argument, or `undefined` if
57
+ * the argument was not provided.
58
+ * @param name - Argument name (without `--` prefix).
59
+ */
60
+ raw(name: string): string | undefined;
61
+ /**
62
+ * Return the validated value of an argument. The return type is
63
+ * determined by the generic parameter `T`, which should match
64
+ * the output type of the argument's Zod schema.
65
+ *
66
+ * The schema handles all type coercion (e.g. `z.coerce.number()`
67
+ * converts string `"42"` → number `42`) and constraint validation
68
+ * (e.g. `z.string().min(1)` rejects empty strings).
69
+ *
70
+ * Use this for value-type arguments that must be present or prompted.
71
+ * For boolean flags, use {@link flag} instead.
72
+ *
73
+ * If the argument was not provided on the command line, prompts
74
+ * the user interactively (when a readline interface is available).
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const name = await args.require<string>('name');
79
+ * const count = await args.require<number>('count');
80
+ * const size = await args.require<string>('size');
81
+ * ```
82
+ *
83
+ * @param name - Argument name (without `--` prefix).
84
+ * @throws {InvalidArgumentsError} When no definition exists for
85
+ * `name`, when schema validation fails, or when the argument is
86
+ * missing and no readline interface is available.
87
+ */
88
+ require<T = unknown>(name: string): Promise<T>;
89
+ /**
90
+ * Return the boolean value of a flag argument. Accepts `"true"`,
91
+ * `"false"`, `"1"`, and `"0"` (case-insensitive for true/false).
92
+ *
93
+ * Unlike {@link require}, this method treats a missing argument as
94
+ * `false` — the convention for CLI flags (`--verbose` → true,
95
+ * absent → false).
96
+ *
97
+ * Don't use `z.coerce.boolean()` in your schemas — Zod 4 uses
98
+ * `Boolean()` which turns `"false"` into `true`. Instead, define
99
+ * the schema as `z.boolean()` and always read the value with
100
+ * this method. The string-to-boolean coercion is handled here
101
+ * before the schema validates the result.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * const verbose = await args.flag('verbose');
106
+ * // --verbose → true
107
+ * // --verbose false → false
108
+ * // (absent) → false
109
+ * ```
110
+ *
111
+ * @param name - Argument name (without `--` prefix).
112
+ * @throws {InvalidArgumentsError} When no definition exists for
113
+ * `name`, or when the value is not a valid boolean string.
114
+ */
115
+ flag(name: string): Promise<boolean>;
116
+ private resolve;
117
+ private promptRequired;
118
+ private requireDef;
119
+ }
120
+ //# sourceMappingURL=command-arguments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-arguments.d.ts","sourceRoot":"","sources":["../src/command-arguments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,iEAAiE;AACjE,MAAM,WAAW,yBAAyB;IACtC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;IAClB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,gBAAgB;IASrB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,OAAO,CAAC;IAVpB;;;;;;OAMG;gBAES,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,EAAE,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,EAC7B,OAAO,CAAC,EAAE,yBAAyB,EAAE,YAAA;IAGjD;;;OAGG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIrC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAYpD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YAkB5B,OAAO;IAUrB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,UAAU;CASrB"}
@@ -0,0 +1,155 @@
1
+ import { InvalidArgumentsError } from './errors.js';
2
+ /**
3
+ * Wraps a parsed argument record (`--name value` pairs) and provides
4
+ * typed accessors that validate and coerce values via the argument's
5
+ * {@link CommandArgumentDefinition} zod schema. When an argument is
6
+ * missing and a readline interface is available, the accessor prompts
7
+ * the user interactively.
8
+ *
9
+ * Every `require*` accessor requires a matching
10
+ * {@link CommandArgumentDefinition} to exist for the requested name.
11
+ * If no definition is found, an {@link InvalidArgumentsError} is thrown.
12
+ *
13
+ * ## Choosing an accessor
14
+ *
15
+ * | Accessor | When to use | Schema examples |
16
+ * |---|---|---|
17
+ * | `require<T>(name)` | Value arg that must be present (or prompted). The Zod schema handles all parsing. | `z.coerce.number()`, `z.string().min(1)`, `z.enum([...])` |
18
+ * | `flag(name)` | CLI flag with `--flag` / `--flag false` semantics. Absent → `false`. | `z.boolean()`, `z.literal(true)` |
19
+ *
20
+ * Don't use `z.coerce.boolean()` or `z.boolean({ coerce: true })` in schemas —
21
+ * Zod 4's boolean coercion uses `Boolean()` which turns `"false"` into `true`.
22
+ * Always use `flag(name)` to read boolean arguments instead.
23
+ */
24
+ export class CommandArguments {
25
+ record;
26
+ rl;
27
+ argDefs;
28
+ /**
29
+ * @param record - Parsed `--name value` pairs.
30
+ * @param rl - Readline interface for interactive prompting, or `null`
31
+ * to disable prompting and throw on missing args.
32
+ * @param argDefs - Optional argument definitions used for schema-based
33
+ * validation. Looked up by name per accessor call.
34
+ */
35
+ constructor(record, rl, argDefs) {
36
+ this.record = record;
37
+ this.rl = rl;
38
+ this.argDefs = argDefs;
39
+ }
40
+ /**
41
+ * Check whether an argument was provided on the command line.
42
+ * @param name - Argument name (without `--` prefix).
43
+ */
44
+ has(name) {
45
+ return name in this.record;
46
+ }
47
+ /**
48
+ * Return the raw string value of an argument, or `undefined` if
49
+ * the argument was not provided.
50
+ * @param name - Argument name (without `--` prefix).
51
+ */
52
+ raw(name) {
53
+ return this.record[name];
54
+ }
55
+ /**
56
+ * Return the validated value of an argument. The return type is
57
+ * determined by the generic parameter `T`, which should match
58
+ * the output type of the argument's Zod schema.
59
+ *
60
+ * The schema handles all type coercion (e.g. `z.coerce.number()`
61
+ * converts string `"42"` → number `42`) and constraint validation
62
+ * (e.g. `z.string().min(1)` rejects empty strings).
63
+ *
64
+ * Use this for value-type arguments that must be present or prompted.
65
+ * For boolean flags, use {@link flag} instead.
66
+ *
67
+ * If the argument was not provided on the command line, prompts
68
+ * the user interactively (when a readline interface is available).
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const name = await args.require<string>('name');
73
+ * const count = await args.require<number>('count');
74
+ * const size = await args.require<string>('size');
75
+ * ```
76
+ *
77
+ * @param name - Argument name (without `--` prefix).
78
+ * @throws {InvalidArgumentsError} When no definition exists for
79
+ * `name`, when schema validation fails, or when the argument is
80
+ * missing and no readline interface is available.
81
+ */
82
+ async require(name) {
83
+ const raw = await this.resolve(name);
84
+ const def = this.requireDef(name);
85
+ const parsed = def.schema.safeParse(raw);
86
+ if (!parsed.success) {
87
+ throw new InvalidArgumentsError(`Argument "${name}": ${parsed.error.issues.map((e) => e.message).join('; ')}`);
88
+ }
89
+ return parsed.data;
90
+ }
91
+ /**
92
+ * Return the boolean value of a flag argument. Accepts `"true"`,
93
+ * `"false"`, `"1"`, and `"0"` (case-insensitive for true/false).
94
+ *
95
+ * Unlike {@link require}, this method treats a missing argument as
96
+ * `false` — the convention for CLI flags (`--verbose` → true,
97
+ * absent → false).
98
+ *
99
+ * Don't use `z.coerce.boolean()` in your schemas — Zod 4 uses
100
+ * `Boolean()` which turns `"false"` into `true`. Instead, define
101
+ * the schema as `z.boolean()` and always read the value with
102
+ * this method. The string-to-boolean coercion is handled here
103
+ * before the schema validates the result.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const verbose = await args.flag('verbose');
108
+ * // --verbose → true
109
+ * // --verbose false → false
110
+ * // (absent) → false
111
+ * ```
112
+ *
113
+ * @param name - Argument name (without `--` prefix).
114
+ * @throws {InvalidArgumentsError} When no definition exists for
115
+ * `name`, or when the value is not a valid boolean string.
116
+ */
117
+ async flag(name) {
118
+ if (!this.has(name))
119
+ return false;
120
+ const raw = this.record[name];
121
+ const lower = raw.toLowerCase();
122
+ const bool = lower === 'true' || lower === '1';
123
+ if (!bool && lower !== 'false' && lower !== '0') {
124
+ throw new InvalidArgumentsError(`Argument "${name}" must be a boolean, got "${raw}"`);
125
+ }
126
+ const def = this.requireDef(name);
127
+ const validated = def.schema.safeParse(bool);
128
+ if (!validated.success) {
129
+ throw new InvalidArgumentsError(`Argument "${name}": ${validated.error.issues.map((e) => e.message).join('; ')}`);
130
+ }
131
+ return validated.data;
132
+ }
133
+ async resolve(name) {
134
+ if (name in this.record) {
135
+ return this.record[name];
136
+ }
137
+ if (this.rl) {
138
+ return await this.promptRequired(name);
139
+ }
140
+ throw new InvalidArgumentsError(`Argument "${name}" is required but not provided`);
141
+ }
142
+ promptRequired(name) {
143
+ return new Promise((resolve) => {
144
+ this.rl.question(`argument [${name}]: `, resolve);
145
+ });
146
+ }
147
+ requireDef(name) {
148
+ const def = this.argDefs?.find((d) => d.name === name);
149
+ if (!def) {
150
+ throw new InvalidArgumentsError(`Argument "${name}" is not defined. Add it to the command's definitions() array.`);
151
+ }
152
+ return def;
153
+ }
154
+ }
155
+ //# sourceMappingURL=command-arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-arguments.js","sourceRoot":"","sources":["../src/command-arguments.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,17 @@
1
+ import { Command, CommandContainer, type CommandContext } from './types.js';
2
+ import type { CommandArgumentDefinition, CommandArguments } from './command-arguments.js';
3
+ import type { z } from 'zod';
4
+ /**
5
+ * Create a leaf command from a name, description, argument definitions,
6
+ * and a handler callback — no need to subclass `Command`.
7
+ */
8
+ export declare function command(name: string, description: string | undefined, argDefs: CommandArgumentDefinition[], execute: (ctx: CommandContext, args: CommandArguments) => void | Promise<void>): Command;
9
+ /**
10
+ * Create a namespace container with an optional list of child commands.
11
+ */
12
+ export declare function container(name: string, description?: string, children?: Command[]): CommandContainer;
13
+ /**
14
+ * Convenience factory for a single argument definition.
15
+ */
16
+ export declare function arg(name: string, description: string | undefined, schema: z.ZodType, position?: number): CommandArgumentDefinition;
17
+ //# sourceMappingURL=command-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-factory.d.ts","sourceRoot":"","sources":["../src/command-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;GAGG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,yBAAyB,EAAE,EACpC,OAAO,EAAE,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC/E,OAAO,CAST;AAED;;GAEG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,OAAO,EAAE,GACrB,gBAAgB,CAYlB;AAED;;GAEG;AACH,wBAAgB,GAAG,CACf,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,MAAM,EAAE,CAAC,CAAC,OAAO,EACjB,QAAQ,CAAC,EAAE,MAAM,GAClB,yBAAyB,CAK3B"}
@@ -0,0 +1,43 @@
1
+ import { Command, CommandContainer } from './types.js';
2
+ /**
3
+ * Create a leaf command from a name, description, argument definitions,
4
+ * and a handler callback — no need to subclass `Command`.
5
+ */
6
+ export function command(name, description, argDefs, execute) {
7
+ return new (class extends Command {
8
+ constructor() {
9
+ super(name, description, argDefs);
10
+ }
11
+ async execute(ctx, args) {
12
+ await execute(ctx, args);
13
+ }
14
+ })();
15
+ }
16
+ /**
17
+ * Create a namespace container with an optional list of child commands.
18
+ */
19
+ export function container(name, description, children) {
20
+ const c = new (class extends CommandContainer {
21
+ constructor() {
22
+ super(name, description);
23
+ }
24
+ })();
25
+ if (children) {
26
+ for (const child of children) {
27
+ c.add(child);
28
+ }
29
+ }
30
+ return c;
31
+ }
32
+ /**
33
+ * Convenience factory for a single argument definition.
34
+ */
35
+ export function arg(name, description, schema, position) {
36
+ const def = { name, schema };
37
+ if (description !== undefined)
38
+ def.description = description;
39
+ if (position !== undefined)
40
+ def.position = position;
41
+ return def;
42
+ }
43
+ //# sourceMappingURL=command-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-factory.js","sourceRoot":"","sources":["../src/command-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAuB,MAAM,YAAY,CAAC;AAI5E;;;GAGG;AACH,MAAM,UAAU,OAAO,CACnB,IAAY,EACZ,WAA+B,EAC/B,OAAoC,EACpC,OAA8E;IAE9E,OAAO,IAAI,CAAC,KAAM,SAAQ,OAAO;QAC7B;YACI,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,GAAmB,EAAE,IAAsB;YACrD,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;KACJ,CAAC,EAAE,CAAC;AACT,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CACrB,IAAY,EACZ,WAAoB,EACpB,QAAoB;IAEpB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAM,SAAQ,gBAAgB;QACzC;YACI,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC7B,CAAC;KACJ,CAAC,EAAE,CAAC;IACL,IAAI,QAAQ,EAAE,CAAC;QACX,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC3B,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CACf,IAAY,EACZ,WAA+B,EAC/B,MAAiB,EACjB,QAAiB;IAEjB,MAAM,GAAG,GAA8B,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACxD,IAAI,WAAW,KAAK,SAAS;QAAE,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC;IAC7D,IAAI,QAAQ,KAAK,SAAS;QAAE,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACpD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Command, CommandContainer, type CommandContext } from './types.js';
2
+ import type { CommandArguments } from './command-arguments.js';
3
+ /**
4
+ * Root of the command tree. Maintains the full set of registered
5
+ * commands and provides lookup, traversal, and completion support.
6
+ */
7
+ export declare class CommandTree extends CommandContainer {
8
+ constructor();
9
+ /**
10
+ * Default execution: prints a global help listing of all
11
+ * registered root commands.
12
+ */
13
+ execute(ctx: CommandContext, _args: CommandArguments): Promise<void>;
14
+ /**
15
+ * Walk the command tree by matching input tokens against
16
+ * command names. Returns the deepest matching command and
17
+ * any remaining (unmatched) tokens.
18
+ *
19
+ * @param tokens - Tokenized input (e.g. `["config", "set", "--theme", "dark"]`).
20
+ * @returns The matched command and unused tokens, or `null` when
21
+ * no command matches.
22
+ */
23
+ find(tokens: string[]): {
24
+ command: Command;
25
+ args: string[];
26
+ } | null;
27
+ /**
28
+ * Returns a shallow copy of all root-level commands.
29
+ * Used by the help system and completer.
30
+ */
31
+ getRoots(): Command[];
32
+ /**
33
+ * Find command names that match a case-insensitive prefix.
34
+ * Used for error suggestions when a command is not found.
35
+ *
36
+ * @param prefix - The user's typed (partial) command name.
37
+ */
38
+ findSuggestions(prefix: string): string[];
39
+ }
40
+ //# sourceMappingURL=command-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-tree.d.ts","sourceRoot":"","sources":["../src/command-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;GAGG;AACH,qBAAa,WAAY,SAAQ,gBAAgB;;IAK7C;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1E;;;;;;;;OAQG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI;IA4BnE;;;OAGG;IACH,QAAQ,IAAI,OAAO,EAAE;IAIrB;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;CAM5C"}
@@ -0,0 +1,77 @@
1
+ import { CommandContainer } from './types.js';
2
+ import { globalHelp } from './commands/help.js';
3
+ /**
4
+ * Root of the command tree. Maintains the full set of registered
5
+ * commands and provides lookup, traversal, and completion support.
6
+ */
7
+ export class CommandTree extends CommandContainer {
8
+ constructor() {
9
+ super('__root__');
10
+ }
11
+ /**
12
+ * Default execution: prints a global help listing of all
13
+ * registered root commands.
14
+ */
15
+ async execute(ctx, _args) {
16
+ const output = globalHelp(this.commands());
17
+ ctx.stdout.write(output + '\n');
18
+ }
19
+ /**
20
+ * Walk the command tree by matching input tokens against
21
+ * command names. Returns the deepest matching command and
22
+ * any remaining (unmatched) tokens.
23
+ *
24
+ * @param tokens - Tokenized input (e.g. `["config", "set", "--theme", "dark"]`).
25
+ * @returns The matched command and unused tokens, or `null` when
26
+ * no command matches.
27
+ */
28
+ find(tokens) {
29
+ if (tokens.length === 0)
30
+ return null;
31
+ let level = this.commands();
32
+ let matched = null;
33
+ let tokenIndex = 0;
34
+ for (const token of tokens) {
35
+ const cmd = level.find((c) => c.name() === token);
36
+ if (!cmd)
37
+ break;
38
+ matched = cmd;
39
+ tokenIndex++;
40
+ if (cmd instanceof CommandContainer) {
41
+ const children = cmd.commands();
42
+ if (children.length > 0) {
43
+ level = children;
44
+ }
45
+ else {
46
+ break;
47
+ }
48
+ }
49
+ else {
50
+ break;
51
+ }
52
+ }
53
+ if (!matched)
54
+ return null;
55
+ return { command: matched, args: tokens.slice(tokenIndex) };
56
+ }
57
+ /**
58
+ * Returns a shallow copy of all root-level commands.
59
+ * Used by the help system and completer.
60
+ */
61
+ getRoots() {
62
+ return [...this.commands()];
63
+ }
64
+ /**
65
+ * Find command names that match a case-insensitive prefix.
66
+ * Used for error suggestions when a command is not found.
67
+ *
68
+ * @param prefix - The user's typed (partial) command name.
69
+ */
70
+ findSuggestions(prefix) {
71
+ const lower = prefix.toLowerCase();
72
+ return this.commands()
73
+ .filter((c) => c.name().toLowerCase().startsWith(lower))
74
+ .map((c) => c.name());
75
+ }
76
+ }
77
+ //# sourceMappingURL=command-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-tree.js","sourceRoot":"","sources":["../src/command-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,gBAAgB,EAAuB,MAAM,YAAY,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,gBAAgB;IAC7C;QACI,KAAK,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,GAAmB,EAAE,KAAuB;QACtD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3C,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,MAAgB;QACjB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAErC,IAAI,KAAK,GAAc,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAI,OAAO,GAAmB,IAAI,CAAC;QACnC,IAAI,UAAU,GAAG,CAAC,CAAC;QAEnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,CAAC;YAClD,IAAI,CAAC,GAAG;gBAAE,MAAM;YAChB,OAAO,GAAG,GAAG,CAAC;YACd,UAAU,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;gBAClC,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAChC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,KAAK,GAAG,QAAQ,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACJ,MAAM;gBACV,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,MAAM;YACV,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC1B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;IAChE,CAAC;IAED;;;OAGG;IACH,QAAQ;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,MAAc;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC,QAAQ,EAAE;aACjB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aACvD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9B,CAAC;CACJ"}
@@ -0,0 +1,10 @@
1
+ import { Command, type CommandContext } from '../types.js';
2
+ import type { CommandArguments } from '../command-arguments.js';
3
+ /**
4
+ * Built-in `clear` command. Clears the terminal screen.
5
+ */
6
+ export declare class ClearCommand extends Command {
7
+ constructor();
8
+ execute(ctx: CommandContext, _args: CommandArguments): void;
9
+ }
10
+ //# sourceMappingURL=clear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,YAAa,SAAQ,OAAO;;IAKrC,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;CAG9D"}
@@ -0,0 +1,13 @@
1
+ import { Command } from '../types.js';
2
+ /**
3
+ * Built-in `clear` command. Clears the terminal screen.
4
+ */
5
+ export class ClearCommand extends Command {
6
+ constructor() {
7
+ super('clear', 'Clear terminal');
8
+ }
9
+ execute(ctx, _args) {
10
+ ctx.stdout.write('\x1Bc');
11
+ }
12
+ }
13
+ //# sourceMappingURL=clear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,aAAa,CAAC;AAG3D;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,OAAO;IACrC;QACI,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,CAAC,GAAmB,EAAE,KAAuB;QAChD,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CACJ"}
@@ -0,0 +1,10 @@
1
+ import { Command, type CommandContext } from '../types.js';
2
+ import type { CommandArguments } from '../command-arguments.js';
3
+ /**
4
+ * Built-in `exit` command. Stops the terminal loop.
5
+ */
6
+ export declare class ExitCommand extends Command {
7
+ constructor();
8
+ execute(ctx: CommandContext, _args: CommandArguments): void;
9
+ }
10
+ //# sourceMappingURL=exit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.d.ts","sourceRoot":"","sources":["../../src/commands/exit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,WAAY,SAAQ,OAAO;;IAKpC,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;CAG9D"}
@@ -0,0 +1,13 @@
1
+ import { Command } from '../types.js';
2
+ /**
3
+ * Built-in `exit` command. Stops the terminal loop.
4
+ */
5
+ export class ExitCommand extends Command {
6
+ constructor() {
7
+ super('exit', 'Exit the terminal');
8
+ }
9
+ execute(ctx, _args) {
10
+ ctx.exit();
11
+ }
12
+ }
13
+ //# sourceMappingURL=exit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit.js","sourceRoot":"","sources":["../../src/commands/exit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,aAAa,CAAC;AAG3D;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAO;IACpC;QACI,KAAK,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,GAAmB,EAAE,KAAuB;QAChD,GAAG,CAAC,IAAI,EAAE,CAAC;IACf,CAAC;CACJ"}
@@ -0,0 +1,40 @@
1
+ import { Command, type CommandContext } from '../types.js';
2
+ import type { CommandArguments } from '../command-arguments.js';
3
+ /**
4
+ * Render a global help listing for a set of root commands.
5
+ * Each command is shown as `name description`, names are
6
+ * left-aligned to the longest command name.
7
+ */
8
+ export declare function globalHelp(commands: Command[]): string;
9
+ /**
10
+ * Render detailed help for a single command, including its
11
+ * name, description, argument definitions, and subcommands.
12
+ */
13
+ export declare function commandHelp(command: Command): string;
14
+ /**
15
+ * Resolve a token path against a command list and render
16
+ * help for the resolved command. Returns an error message
17
+ * if the path does not match any command.
18
+ */
19
+ export declare function scopedHelp(commands: Command[], pathTokens: string[]): string;
20
+ /**
21
+ * Walk the command tree matching each token to a command name.
22
+ * Returns the deepest matching command, or `undefined` if a token
23
+ * cannot be matched or extra tokens trail a leaf node.
24
+ */
25
+ export declare function resolveCommand(commands: Command[], tokens: string[]): Command | undefined;
26
+ /**
27
+ * Built-in `help` command. Lists all commands or shows detailed
28
+ * help for a specific command by name.
29
+ *
30
+ * @example
31
+ * ```
32
+ * > help # list all commands
33
+ * > help --command config # show help for the "config" command
34
+ * ```
35
+ */
36
+ export declare class HelpCommand extends Command {
37
+ constructor();
38
+ execute(ctx: CommandContext, args: CommandArguments): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAStD;AAeD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CA0BpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAM5E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,CAoBzF;AAED;;;;;;;;;GASG;AACH,qBAAa,WAAY,SAAQ,OAAO;;IAY9B,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAc5E"}