@visulima/cerebro 2.0.3 → 2.1.1

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 (71) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE.md +2375 -8
  3. package/README.md +279 -24
  4. package/dist/cli.d.ts +203 -0
  5. package/dist/commands/completion-command.d.ts +6 -6
  6. package/dist/commands/help-command.d.ts +6 -8
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -6
  9. package/dist/commands/version-command.d.ts +3 -6
  10. package/dist/constants.d.ts +29 -0
  11. package/dist/default-env.d.ts +7 -0
  12. package/dist/default-options.d.ts +3 -0
  13. package/dist/empty-toolbox.d.ts +15 -0
  14. package/dist/errors/cerebro-error.d.ts +10 -0
  15. package/dist/errors/command-not-found-error.d.ts +9 -0
  16. package/dist/errors/command-validation-error.d.ts +10 -0
  17. package/dist/errors/completion-error.d.ts +9 -0
  18. package/dist/errors/conflicting-options-error.d.ts +10 -0
  19. package/dist/errors/plugin-error.d.ts +9 -0
  20. package/dist/errors/update-notifier-error.d.ts +7 -0
  21. package/dist/index.d.ts +94 -50
  22. package/dist/index.js +1 -1
  23. package/dist/logger/create-pail-logger.d.ts +8 -5
  24. package/dist/logger/create-pail-logger.js +1 -1
  25. package/dist/packem_chunks/has-new-version.js +1 -1
  26. package/dist/packem_shared/{Cerebro-C23kXfEn.js → Cerebro-BqHqYEQJ.js} +3 -3
  27. package/dist/packem_shared/{help-command-C_CdZQSd.js → help-command-Ddt6rdio.js} +1 -1
  28. package/dist/plugin-manager.d.ts +53 -0
  29. package/dist/plugins/error-handler-plugin.d.ts +16 -10
  30. package/dist/plugins/runtime-version-check-plugin.d.ts +15 -10
  31. package/dist/plugins/update-notifier/cache.d.ts +11 -0
  32. package/dist/plugins/update-notifier/get-distribution-version.d.ts +2 -0
  33. package/dist/plugins/update-notifier/has-new-version.d.ts +14 -0
  34. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +9 -21
  35. package/dist/types/cli.d.ts +105 -0
  36. package/dist/types/command-line-usage.d.ts +37 -0
  37. package/dist/types/command.d.ts +136 -0
  38. package/dist/types/option-types.d.ts +83 -0
  39. package/dist/types/options.d.ts +4 -0
  40. package/dist/types/plugin.d.ts +53 -0
  41. package/dist/types/toolbox.d.ts +96 -0
  42. package/dist/util/arg-processing/get-boolean-values.d.ts +7 -0
  43. package/dist/util/arg-processing/get-parameter-option.d.ts +7 -0
  44. package/dist/util/arg-processing/map-option-type-label.d.ts +3 -0
  45. package/dist/util/arg-processing/option-is-boolean.d.ts +9 -0
  46. package/dist/util/arg-processing/remove-boolean-values.d.ts +9 -0
  47. package/dist/util/command-line-commands.d.ts +10 -0
  48. package/dist/util/command-line-usage/get-terminal-width.d.ts +7 -0
  49. package/dist/util/command-line-usage/index.d.ts +3 -0
  50. package/dist/util/command-line-usage/section/base-section.d.ts +8 -0
  51. package/dist/util/command-line-usage/section/content-section.d.ts +65 -0
  52. package/dist/util/command-line-usage/section/option-list-section.d.ts +44 -0
  53. package/dist/util/command-processing/command-processor.d.ts +37 -0
  54. package/dist/util/command-processing/command-validation.d.ts +17 -0
  55. package/dist/util/command-processing/nested-command-parser.d.ts +25 -0
  56. package/dist/util/command-processing/option-processor.d.ts +44 -0
  57. package/dist/util/data-processing/list-missing-arguments.d.ts +15 -0
  58. package/dist/util/data-processing/merge-arguments.d.ts +7 -0
  59. package/dist/util/general/find-alternatives.d.ts +8 -0
  60. package/dist/util/general/hide-bin.d.ts +2 -0
  61. package/dist/util/general/parse-raw-command.d.ts +7 -0
  62. package/dist/util/general/register-exception-handler.d.ts +9 -0
  63. package/dist/util/general/runtime-process.d.ts +65 -0
  64. package/dist/util/general/semver-gt.d.ts +2 -0
  65. package/dist/util/general/validate-input.d.ts +24 -0
  66. package/dist/util/process-env-variables.d.ts +9 -0
  67. package/dist/util/security.d.ts +58 -0
  68. package/dist/util/text-processing/template-format.d.ts +5 -0
  69. package/package.json +6 -6
  70. package/dist/packem_shared/index.d-BkzZomTF.d.ts +0 -65
  71. package/dist/packem_shared/plugin-manager-BjEuiNxv.d.ts +0 -147
package/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
  <p>
4
4
  Cerebro is a delightful toolkit for building cross-runtime command-line interfaces (CLIs) for Node.js, Deno, and Bun, built on top of
5
5
 
6
- [boxen](https://github.com/visulima/visulima/tree/main/packages/boxen),
7
- [colorize](https://github.com/visulima/visulima/tree/main/packages/colorize),
8
- [cli-table3](https://github.com/cli-table/cli-table3),
9
- [command-line-args](https://github.com/75lb/command-line-args) and
6
+ [@visulima/boxen](https://github.com/visulima/visulima/tree/main/packages/boxen),
7
+ [@visulima/colorize](https://github.com/visulima/visulima/tree/main/packages/colorize),
8
+ [@visulima/command-line-args](https://github.com/visulima/visulima/tree/main/packages/command-line-args),
9
+ [@visulima/tabular](https://github.com/visulima/visulima/tree/main/packages/tabular) and
10
10
  [fastest-levenshtein](https://github.com/ka-weihe/fastest-levenshtein)
11
11
 
12
12
  <br />
@@ -53,30 +53,228 @@ pnpm add @visulima/cerebro
53
53
  ## Usage
54
54
 
55
55
  ```ts
56
- import Cli from "@visulima/cerebro";
56
+ import { Cerebro } from "@visulima/cerebro";
57
57
 
58
58
  // Create a CLI runtime
59
- const cli = new Cli("cerebro");
59
+ const cli = new Cerebro("my-cli");
60
60
 
61
- // Your command
61
+ // Add commands with options and arguments
62
62
  cli.addCommand({
63
- name: "main:colors",
64
- description: "Output colors", // This is used in the help output
65
- execute: ({ logger }) => {
66
- logger.info("Colors command");
63
+ name: "build",
64
+ description: "Build the project",
65
+ options: [
66
+ {
67
+ name: "output",
68
+ alias: "o",
69
+ type: String,
70
+ description: "Output directory",
71
+ defaultValue: "dist"
72
+ },
73
+ {
74
+ name: "production",
75
+ alias: "p",
76
+ type: Boolean,
77
+ description: "Build for production"
78
+ },
79
+ {
80
+ name: "watch",
81
+ alias: "w",
82
+ type: Boolean,
83
+ description: "Watch for changes"
84
+ }
85
+ ],
86
+ argument: {
87
+ name: "target",
88
+ description: "Build target (optional)",
89
+ type: String
90
+ },
91
+ execute: ({ options, argument, logger, env }) => {
92
+ const target = argument[0] || "all";
93
+ const outputDir = options.output;
94
+
95
+ logger.info(`Building target: ${target}`);
96
+ logger.info(`Output directory: ${outputDir}`);
97
+
98
+ if (options.production) {
99
+ logger.info("Production build enabled");
100
+ }
101
+
102
+ if (options.watch) {
103
+ logger.info("Watch mode enabled");
104
+ }
105
+
106
+ if (env.NODE_ENV) {
107
+ logger.info(`Environment: ${env.NODE_ENV}`);
108
+ }
109
+ },
110
+ });
111
+
112
+ // Add another command with environment variables
113
+ cli.addCommand({
114
+ name: "deploy",
115
+ description: "Deploy the application",
116
+ env: [
117
+ {
118
+ name: "DEPLOY_ENV",
119
+ description: "Deployment environment",
120
+ type: String,
121
+ defaultValue: "staging"
122
+ },
123
+ {
124
+ name: "API_KEY",
125
+ description: "API key for deployment",
126
+ type: String
127
+ }
128
+ ],
129
+ execute: ({ env, logger }) => {
130
+ logger.info(`Deploying to ${env.DEPLOY_ENV}`);
131
+ if (env.API_KEY) {
132
+ logger.info("Using provided API key");
133
+ }
67
134
  },
68
135
  });
69
136
 
70
137
  await cli.run();
71
138
  ```
72
139
 
73
- Now you can run your CLI with `node index.js` (or `deno run index.js`, `bun index.js`) and you should see the following output:
140
+ Now you can run your CLI with `node index.js` (or `deno run index.js`, `bun index.js`). Here are some example usages:
141
+
142
+ ```bash
143
+ # Show help
144
+ node index.js --help
145
+
146
+ # Build with default options
147
+ node index.js build
148
+
149
+ # Build specific target with custom output
150
+ node index.js build --output ./build client
151
+
152
+ # Production build with watch mode
153
+ node index.js build --production --watch
154
+
155
+ # Deploy (uses environment variables)
156
+ node index.js deploy
157
+ ```
158
+
159
+ You should see help output and command execution based on the options provided:
74
160
 
75
161
  ![Cli Output](./__assets__/cli_output.png)
76
162
 
163
+ ## Toolbox API
164
+
165
+ When your command's `execute` function is called, it receives a toolbox object with various utilities and context. Here's what you can access:
166
+
167
+ ### Core Properties
168
+
169
+ - **`logger`**: Logger instance for output (debug, info, warn, error)
170
+ - **`options`**: Parsed command-line options (camelCase keys)
171
+ - **`argument`**: Array of positional arguments
172
+ - **`env`**: Environment variables (camelCase keys)
173
+ - **`runtime`**: Reference to the CLI instance
174
+ - **`argv`**: Original command-line arguments array
175
+
176
+ ### Example Usage
177
+
178
+ ```ts
179
+ cli.addCommand({
180
+ name: "example",
181
+ description: "Example command showing toolbox usage",
182
+ options: [
183
+ { name: "verbose", alias: "v", type: Boolean, description: "Verbose output" },
184
+ { name: "count", alias: "c", type: Number, description: "Count value", defaultValue: 1 }
185
+ ],
186
+ argument: {
187
+ name: "input",
188
+ description: "Input file",
189
+ type: String
190
+ },
191
+ env: [
192
+ { name: "DEBUG", type: Boolean, description: "Debug mode" }
193
+ ],
194
+ execute: ({ logger, options, argument, env, runtime, argv }) => {
195
+ // Use logger for output
196
+ logger.info("Command started");
197
+
198
+ // Access parsed options
199
+ if (options.verbose) {
200
+ logger.debug(`Count: ${options.count}`);
201
+ }
202
+
203
+ // Access positional arguments
204
+ if (argument.length > 0) {
205
+ logger.info(`Processing file: ${argument[0]}`);
206
+ }
207
+
208
+ // Access environment variables
209
+ if (env.debug) {
210
+ logger.debug("Debug mode enabled");
211
+ }
212
+
213
+ // Access CLI instance
214
+ logger.info(`CLI name: ${runtime.cliName}`);
215
+
216
+ // Access original argv
217
+ logger.debug(`Full command: ${argv.join(' ')}`);
218
+ },
219
+ });
220
+ ```
221
+
222
+ ## Built-in Commands
223
+
224
+ Cerebro comes with several built-in commands that are automatically available:
225
+
226
+ ### Help Command
227
+
228
+ The help command is automatically added to your CLI and provides usage information for all commands.
229
+
230
+ ```bash
231
+ my-cli help
232
+ my-cli help <command>
233
+ ```
234
+
235
+ ### Version Command
236
+
237
+ Display version information for your CLI.
238
+
239
+ ```ts
240
+ import { Cerebro } from "@visulima/cerebro";
241
+ import versionCommand from "@visulima/cerebro/command/version";
242
+
243
+ const cli = new Cerebro("my-cli", {
244
+ packageName: "my-cli",
245
+ packageVersion: "1.0.0"
246
+ });
247
+
248
+ cli.addCommand(versionCommand);
249
+
250
+ await cli.run();
251
+ ```
252
+
253
+ ```bash
254
+ my-cli version
255
+ ```
256
+
257
+ ### Readme Generator Command
258
+
259
+ Generate README documentation for your CLI commands.
260
+
261
+ ```ts
262
+ import { Cerebro } from "@visulima/cerebro";
263
+ import readmeCommand from "@visulima/cerebro/command/readme-generator";
264
+
265
+ const cli = new Cerebro("my-cli");
266
+ cli.addCommand(readmeCommand);
267
+
268
+ await cli.run();
269
+ ```
270
+
271
+ ```bash
272
+ my-cli readme-generator
273
+ ```
274
+
77
275
  ## Shell Completions
78
276
 
79
- Cerebro supports shell autocompletions for bash, zsh, fish, and powershell through the optional `@bomb.sh/tab` integration.
277
+ Cerebro supports intelligent shell autocompletions for **bash**, **zsh**, **fish**, and **powershell** through the optional `@bomb.sh/tab` integration. The completion system automatically detects your current shell and runtime, providing context-aware suggestions for commands, options, and arguments.
80
278
 
81
279
  ### Installation
82
280
 
@@ -86,17 +284,27 @@ To enable completions, first install the optional peer dependency:
86
284
  pnpm add @bomb.sh/tab
87
285
  ```
88
286
 
287
+ Or with other package managers:
288
+
289
+ ```sh
290
+ npm install @bomb.sh/tab
291
+ yarn add @bomb.sh/tab
292
+ ```
293
+
89
294
  ### Adding Completion Command
90
295
 
91
- Import and add the completion command to your CLI:
296
+ Import and add the completion command to your CLI. The completion command supports two options:
297
+
298
+ - **`--shell`**: Shell type (bash, zsh, fish, powershell) - auto-detected by default
299
+ - **`--runtime`**: JavaScript runtime (node, bun, deno) - auto-detected by default
92
300
 
93
301
  ```ts
94
- import Cli from "@visulima/cerebro";
302
+ import { Cerebro } from "@visulima/cerebro";
95
303
  import completionCommand from "@visulima/cerebro/command/completion";
96
304
 
97
- const cli = new Cli("my-cli");
305
+ const cli = new Cerebro("my-cli");
98
306
 
99
- // Add your commands
307
+ // Add your commands with options
100
308
  cli.addCommand({
101
309
  name: "build",
102
310
  description: "Build the project",
@@ -107,6 +315,12 @@ cli.addCommand({
107
315
  type: String,
108
316
  description: "Output directory",
109
317
  },
318
+ {
319
+ name: "production",
320
+ alias: "p",
321
+ type: Boolean,
322
+ description: "Production build",
323
+ },
110
324
  ],
111
325
  execute: ({ options }) => {
112
326
  console.log(`Building to ${options.output || "dist"}`);
@@ -121,28 +335,69 @@ await cli.run();
121
335
 
122
336
  ### Generating Completion Scripts
123
337
 
124
- Users can generate completion scripts for their shell:
338
+ Users can generate completion scripts for their shell. The completion command will automatically detect your shell and runtime, but you can override them if needed:
125
339
 
126
340
  ```bash
127
- # For zsh
341
+ # Auto-detect shell and runtime (recommended)
342
+ my-cli completion > ~/.my-cli-completion.sh
343
+ echo 'source ~/.my-cli-completion.sh' >> ~/.bashrc # or ~/.zshrc
344
+
345
+ # Explicitly specify shell
128
346
  my-cli completion --shell=zsh > ~/.my-cli-completion.zsh
129
- echo 'source ~/.my-cli-completion.zsh' >> ~/.zshrc
347
+ my-cli completion --shell=bash > ~/.my-cli-completion.bash
348
+ my-cli completion --shell=fish > ~/.config/fish/completions/my-cli.fish
349
+ my-cli completion --shell=powershell > ~/.my-cli-completion.ps1
350
+
351
+ # Override runtime detection
352
+ my-cli completion --runtime=node --shell=zsh > ~/.my-cli-completion.zsh
353
+ ```
130
354
 
131
- # For bash
355
+ ### Setup Instructions
356
+
357
+ **Bash:**
358
+ ```bash
132
359
  my-cli completion --shell=bash > ~/.my-cli-completion.bash
133
360
  echo 'source ~/.my-cli-completion.bash' >> ~/.bashrc
361
+ source ~/.bashrc
362
+ ```
134
363
 
135
- # For fish
364
+ **Zsh:**
365
+ ```bash
366
+ my-cli completion --shell=zsh > ~/.my-cli-completion.zsh
367
+ echo 'source ~/.my-cli-completion.zsh' >> ~/.zshrc
368
+ source ~/.zshrc
369
+ ```
370
+
371
+ **Fish:**
372
+ ```bash
136
373
  my-cli completion --shell=fish > ~/.config/fish/completions/my-cli.fish
137
374
  ```
138
375
 
139
- After setting up, users can use `TAB` to autocomplete commands and options.
376
+ **PowerShell:**
377
+ ```powershell
378
+ my-cli completion --shell=powershell > $PROFILE.CurrentUserAllHosts
379
+ . $PROFILE.CurrentUserAllHosts
380
+ ```
381
+
382
+ After setting up, users can press `TAB` to autocomplete:
383
+ - Command names
384
+ - Option flags (both long `--option` and short `-o`)
385
+ - Option values (when applicable)
386
+ - Subcommands
387
+
388
+ ### Troubleshooting
389
+
390
+ If completions don't work:
391
+ 1. Ensure `@bomb.sh/tab` is installed
392
+ 2. Verify the completion script was sourced in your shell profile
393
+ 3. Try restarting your shell or running `source ~/.bashrc` (or equivalent)
394
+ 4. Check that your CLI name matches the completion script filename
140
395
 
141
396
  ## Supported Runtimes
142
397
 
143
398
  Cerebro supports multiple JavaScript runtimes:
144
399
 
145
- - **Node.js**: 18+ (follows [Node.js' release schedule](https://github.com/nodejs/release#release-schedule))
400
+ - **Node.js**: >=20.19 <=25.x (follows [Node.js' release schedule](https://github.com/nodejs/release#release-schedule))
146
401
  - **Deno**: 1.0+
147
402
  - **Bun**: 1.0+
148
403
 
package/dist/cli.d.ts ADDED
@@ -0,0 +1,203 @@
1
+ import PluginManager from "./plugin-manager.d.ts";
2
+ import type { Cli as ICli, CliRunOptions, CommandSection as ICommandSection, ExtendedLogger, RunCommandOptions } from "./types/cli.d.ts";
3
+ import type { Command as ICommand, OptionDefinition } from "./types/command.d.ts";
4
+ import type { Plugin } from "./types/plugin.d.ts";
5
+ export type CliOptions<T extends ExtendedLogger = ExtendedLogger> = {
6
+ argv?: ReadonlyArray<string>;
7
+ cwd?: string;
8
+ logger?: T;
9
+ packageName?: string;
10
+ packageVersion?: string;
11
+ };
12
+ export declare class Cli<T extends ExtendedLogger = ExtendedLogger> implements ICli {
13
+ #private;
14
+ /**
15
+ * Create a new CLI instance.
16
+ * @param cliName
17
+ * @param options The options for the CLI.
18
+ * @param options.argv The command line arguments.
19
+ * @param options.cwd The current working directory.
20
+ * @param options.logger The logger to use.
21
+ * @param options.packageName
22
+ * @param options.packageVersion
23
+ */
24
+ constructor(cliName: string, options?: CliOptions<T>);
25
+ /**
26
+ * Sets the command section configuration for help display.
27
+ *
28
+ * This affects how the CLI name and version are displayed in help output.
29
+ * @param commandSection The command section configuration
30
+ * @returns The CLI instance for method chaining
31
+ * @example
32
+ * ```typescript
33
+ * cli.setCommandSection({
34
+ * header: 'My App v2.0.0',
35
+ * footer: 'For more info, visit https://example.com'
36
+ * });
37
+ * ```
38
+ */
39
+ setCommandSection(commandSection: ICommandSection): this;
40
+ /**
41
+ * Gets the current command section configuration.
42
+ * @returns The command section configuration
43
+ */
44
+ getCommandSection(): ICommandSection;
45
+ /**
46
+ * Sets the default command to run when no command is specified.
47
+ *
48
+ * By default, this is set to 'help'. The command must already be registered
49
+ * with the CLI instance.
50
+ * @param commandName The command name to use as the default
51
+ * @returns The CLI instance for method chaining
52
+ * @example
53
+ * ```typescript
54
+ * cli.setDefaultCommand('start');
55
+ * ```
56
+ */
57
+ setDefaultCommand(commandName: string): this;
58
+ /**
59
+ * Gets the current default command.
60
+ * @returns The name of the default command
61
+ */
62
+ get defaultCommand(): string;
63
+ /**
64
+ * Adds a command to the CLI.
65
+ *
66
+ * Commands define the available operations that users can execute.
67
+ * Each command can have options, arguments, aliases, and custom execution logic.
68
+ * @template OD - The option definition type for the command
69
+ * @param command The command configuration object
70
+ * @returns The CLI instance for method chaining
71
+ * @throws {CerebroError} If the command name already exists or validation fails
72
+ * @example
73
+ * ```typescript
74
+ * cli.addCommand({
75
+ * name: 'build',
76
+ * description: 'Build the project',
77
+ * options: [
78
+ * {
79
+ * name: 'output',
80
+ * alias: 'o',
81
+ * type: String,
82
+ * description: 'Output directory'
83
+ * }
84
+ * ],
85
+ * execute: ({ options }) => {
86
+ * console.log(`Building to ${options.output || 'dist'}`);
87
+ * }
88
+ * });
89
+ * ```
90
+ */
91
+ addCommand<OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: ICommand<OD>): this;
92
+ /**
93
+ * Adds a plugin to extend the CLI functionality.
94
+ *
95
+ * Plugins can hook into various lifecycle events and modify the toolbox
96
+ * to provide additional functionality to commands.
97
+ * @param plugin The plugin to register
98
+ * @returns The CLI instance for method chaining
99
+ * @example
100
+ * ```typescript
101
+ * cli.addPlugin({
102
+ * name: 'logger',
103
+ * execute: (toolbox) => {
104
+ * toolbox.logger = createCustomLogger();
105
+ * }
106
+ * });
107
+ * ```
108
+ */
109
+ addPlugin(plugin: Plugin): this;
110
+ /**
111
+ * Gets the plugin manager instance for advanced plugin management.
112
+ * @returns The plugin manager instance
113
+ */
114
+ getPluginManager(): PluginManager;
115
+ /**
116
+ * Gets the CLI application name.
117
+ */
118
+ getCliName(): string;
119
+ /**
120
+ * Gets the package version if configured.
121
+ * @returns The package version or undefined
122
+ */
123
+ getPackageVersion(): string | undefined;
124
+ /**
125
+ * Gets the package name if configured.
126
+ * @returns The package name or undefined
127
+ */
128
+ getPackageName(): string | undefined;
129
+ /**
130
+ * Gets all registered commands.
131
+ * @returns A map of command names to command definitions
132
+ */
133
+ getCommands(): Map<string, ICommand>;
134
+ /**
135
+ * Gets the current working directory.
136
+ * @returns The current working directory path
137
+ */
138
+ getCwd(): string;
139
+ /**
140
+ * Disposes the CLI instance and cleans up resources.
141
+ *
142
+ * This method removes event listeners and performs cleanup to prevent memory leaks.
143
+ * Call this method when the CLI instance is no longer needed, especially in long-running
144
+ * processes or when creating multiple CLI instances.
145
+ * @example
146
+ * ```typescript
147
+ * const cli = new Cerebro('my-app');
148
+ * // ... use the cli
149
+ * cli.dispose(); // Clean up when done
150
+ * ```
151
+ */
152
+ dispose(): void;
153
+ /**
154
+ * Runs the CLI application.
155
+ *
156
+ * This method parses command line arguments, executes the appropriate command,
157
+ * and handles the complete CLI lifecycle including plugin initialization,
158
+ * error handling, process termination, and automatic cleanup.
159
+ * @param extraOptions Additional options to pass to commands
160
+ * @param extraOptions.shouldExitProcess Whether to exit the process after execution (default: true)
161
+ * @param extraOptions.autoDispose Whether to automatically cleanup/dispose resources after execution (default: true)
162
+ * @returns A promise that resolves when execution completes
163
+ * @throws {CommandNotFoundError} If the specified command doesn't exist
164
+ * @throws {Error} If command arguments are invalid or conflicting options are provided
165
+ * @example
166
+ * ```typescript
167
+ * // Run with default behavior (exits process and auto-disposes)
168
+ * await cli.run();
169
+ *
170
+ * // Run without exiting (for testing)
171
+ * await cli.run({ shouldExitProcess: false });
172
+ *
173
+ * // Run without auto-disposing (for reuse)
174
+ * await cli.run({ autoDispose: false });
175
+ * ```
176
+ */
177
+ run(extraOptions?: CliRunOptions): Promise<void>;
178
+ /**
179
+ * Runs a command programmatically from within another command.
180
+ *
181
+ * This method allows commands to call other commands during execution,
182
+ * enabling composition of commands and reusable command logic.
183
+ * @param commandName The name of the command to execute
184
+ * @param options Optional options including argv and other command options
185
+ * @returns A promise that resolves with the command's result
186
+ * @throws {CommandNotFoundError} If the specified command doesn't exist
187
+ * @throws {CerebroError} If command validation fails
188
+ * @example
189
+ * ```typescript
190
+ * cli.addCommand({
191
+ * name: 'deploy',
192
+ * execute: async ({ runtime, logger }) => {
193
+ * logger.info('Building...');
194
+ * await runtime.runCommand('build', { argv: ['--production'] });
195
+ *
196
+ * logger.info('Testing...');
197
+ * await runtime.runCommand('test', { argv: ['--coverage'] });
198
+ * }
199
+ * });
200
+ * ```
201
+ */
202
+ runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
203
+ }
@@ -1,6 +1,6 @@
1
- import { b as Command } from '../packem_shared/plugin-manager-BjEuiNxv.js';
2
- import '@visulima/tabular';
3
-
4
- declare const completionCommand: Command;
5
-
6
- export { completionCommand as default };
1
+ import type { Command as ICommand } from "../types/command.d.ts";
2
+ /**
3
+ * Generates shell completion scripts for the CLI application.
4
+ */
5
+ declare const completionCommand: ICommand;
6
+ export default completionCommand;
@@ -1,12 +1,10 @@
1
- import { b as Command, O as OptionDefinition, T as Toolbox } from '../packem_shared/plugin-manager-BjEuiNxv.js';
2
- import '@visulima/tabular';
3
-
4
- declare class HelpCommand implements Command {
1
+ import type { Command as ICommand, OptionDefinition } from "../types/command.d.ts";
2
+ import type { Toolbox as IToolbox } from "../types/toolbox.d.ts";
3
+ declare class HelpCommand implements ICommand {
5
4
  name: string;
6
5
  options: OptionDefinition<string>[];
7
6
  private readonly commands;
8
- constructor(commands: Map<string, Command>);
9
- execute(toolbox: Toolbox): void;
7
+ constructor(commands: Map<string, ICommand>);
8
+ execute(toolbox: IToolbox): void;
10
9
  }
11
-
12
- export { HelpCommand as default };
10
+ export default HelpCommand;
@@ -1 +1 @@
1
- import"@visulima/colorize";import{O as p}from"../packem_shared/help-command-C_CdZQSd.js";import"../packem_shared/index-DQ3pvLQH.js";export{p as default};
1
+ import"@visulima/colorize";import{A as p}from"../packem_shared/help-command-Ddt6rdio.js";import"../packem_shared/index-DQ3pvLQH.js";export{p as default};
@@ -1,6 +1,6 @@
1
- import { b as Command } from '../packem_shared/plugin-manager-BjEuiNxv.js';
2
- import '@visulima/tabular';
3
-
4
- declare const readmeCommand: Command;
5
-
6
- export { readmeCommand as default };
1
+ import type { Command as ICommand } from "../types/command.d.ts";
2
+ /**
3
+ * Generates README documentation for cerebro CLI commands.
4
+ */
5
+ declare const readmeCommand: ICommand;
6
+ export default readmeCommand;
@@ -1,6 +1,3 @@
1
- import { b as Command } from '../packem_shared/plugin-manager-BjEuiNxv.js';
2
- import '@visulima/tabular';
3
-
4
- declare const _default: Command;
5
-
6
- export { _default as default };
1
+ import type { Command as ICommand } from "../types/command.d.ts";
2
+ declare const _default: ICommand;
3
+ export default _default;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Output with this option will be formatted.
3
+ */
4
+ export declare const OUTPUT_NORMAL = 1;
5
+ /**
6
+ * Output with this option will be passed as-is.
7
+ */
8
+ export declare const OUTPUT_RAW = 2;
9
+ /**
10
+ * Output with this option will have any formatting stripped away.
11
+ */
12
+ export declare const OUTPUT_PLAIN = 4;
13
+ /**
14
+ * Output with this verbosity won't write anything at all.
15
+ */
16
+ export declare const VERBOSITY_QUIET = 16;
17
+ /**
18
+ * Output with this verbosity will write default content.
19
+ */
20
+ export declare const VERBOSITY_NORMAL = 32;
21
+ /**
22
+ * Output with this verbosity will be more detailed.
23
+ */
24
+ export declare const VERBOSITY_VERBOSE = 64;
25
+ /**
26
+ * Output with this verbosity will reveal internals.
27
+ */
28
+ export declare const VERBOSITY_DEBUG = 128;
29
+ export declare const POSITIONALS_KEY = "positionals";
@@ -0,0 +1,7 @@
1
+ import type { EnvDefinition } from "./types/command.d.ts";
2
+ /**
3
+ * Default environment variables used by Cerebro CLI framework.
4
+ * These are displayed in the help output.
5
+ */
6
+ declare const defaultEnv: (EnvDefinition<string> | EnvDefinition<number> | EnvDefinition<boolean>)[];
7
+ export default defaultEnv;
@@ -0,0 +1,3 @@
1
+ import type { OptionDefinition } from "./types/command.d.ts";
2
+ declare const defaultOptions: OptionDefinition<boolean>[];
3
+ export default defaultOptions;