@visulima/cerebro 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (89) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/LICENSE.md +589 -4096
  3. package/README.md +26 -0
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +2 -2
  6. package/dist/commands/help-command.d.ts +9 -9
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +20 -20
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/index.d.ts +422 -95
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +779 -8
  14. package/dist/logger/create-pail-logger.js +1 -1
  15. package/dist/packem_chunks/has-new-version.js +1 -1
  16. package/dist/packem_shared/Cerebro-DVWKQlmP.js +4 -0
  17. package/dist/packem_shared/VisulimaError-Bh91XNXu.js +76 -0
  18. package/dist/packem_shared/index-B0BiusY7.js +6 -0
  19. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  20. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  21. package/dist/packem_shared/plugin-manager.d-Dz-wu1tI.d.ts +544 -0
  22. package/dist/packem_shared/renderError-B_XyYPKJ-B65kP-Ou.js +24 -0
  23. package/dist/packem_shared/{runtime-process-G-n-wOub.js → runtime-process-DKHFvYkv.js} +1 -1
  24. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  25. package/dist/plugins/error-handler-plugin.js +1 -1
  26. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  27. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  28. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  29. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  30. package/dist/util/general/compile-cache.d.ts +41 -0
  31. package/dist/util/general/compile-cache.js +1 -0
  32. package/dist/util/general/heap-tuning.d.ts +18 -0
  33. package/dist/util/general/heap-tuning.js +1 -0
  34. package/package.json +52 -44
  35. package/dist/cli.d.ts +0 -203
  36. package/dist/constants.d.ts +0 -29
  37. package/dist/default-env.d.ts +0 -7
  38. package/dist/default-options.d.ts +0 -3
  39. package/dist/empty-toolbox.d.ts +0 -15
  40. package/dist/errors/cerebro-error.d.ts +0 -10
  41. package/dist/errors/command-not-found-error.d.ts +0 -9
  42. package/dist/errors/command-validation-error.d.ts +0 -10
  43. package/dist/errors/completion-error.d.ts +0 -9
  44. package/dist/errors/conflicting-options-error.d.ts +0 -10
  45. package/dist/errors/plugin-error.d.ts +0 -9
  46. package/dist/errors/update-notifier-error.d.ts +0 -7
  47. package/dist/packem_shared/Cerebro-aPZjbfzf.js +0 -4
  48. package/dist/packem_shared/VisulimaError-BJideSBf.js +0 -76
  49. package/dist/packem_shared/help-command-CIRIXN03.js +0 -1
  50. package/dist/packem_shared/index-DQ3pvLQH.js +0 -6
  51. package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +0 -24
  52. package/dist/plugin-manager.d.ts +0 -53
  53. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  54. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  55. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  56. package/dist/types/cli.d.ts +0 -102
  57. package/dist/types/command-line-usage.d.ts +0 -37
  58. package/dist/types/command.d.ts +0 -136
  59. package/dist/types/option-types.d.ts +0 -83
  60. package/dist/types/options.d.ts +0 -4
  61. package/dist/types/plugin.d.ts +0 -53
  62. package/dist/types/toolbox.d.ts +0 -96
  63. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  64. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  65. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  66. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  67. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  68. package/dist/util/command-line-commands.d.ts +0 -10
  69. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  70. package/dist/util/command-line-usage/index.d.ts +0 -3
  71. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  72. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  73. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  74. package/dist/util/command-processing/command-processor.d.ts +0 -37
  75. package/dist/util/command-processing/command-validation.d.ts +0 -17
  76. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  77. package/dist/util/command-processing/option-processor.d.ts +0 -44
  78. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  79. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  80. package/dist/util/general/find-alternatives.d.ts +0 -8
  81. package/dist/util/general/hide-bin.d.ts +0 -2
  82. package/dist/util/general/parse-raw-command.d.ts +0 -7
  83. package/dist/util/general/register-exception-handler.d.ts +0 -9
  84. package/dist/util/general/runtime-process.d.ts +0 -65
  85. package/dist/util/general/semver-gt.d.ts +0 -2
  86. package/dist/util/general/validate-input.d.ts +0 -24
  87. package/dist/util/process-env-variables.d.ts +0 -9
  88. package/dist/util/security.d.ts +0 -58
  89. package/dist/util/text-processing/template-format.d.ts +0 -5
package/dist/index.d.ts CHANGED
@@ -1,99 +1,426 @@
1
- import type { CliOptions } from './cli.d.ts';
2
- import { Cli } from './cli.d.ts';
1
+ import { a as CommandSection, O as OptionDefinition, C as Command, P as Plugin, b as PluginManager, c as CliRunOptions, R as RunCommandOptions, d as Cli$1, L as LazyCommandModule } from "./packem_shared/plugin-manager.d-Dz-wu1tI.js";
2
+ export { type A as ArgumentDefinition, type e as CommandExecute, type E as EnvDefinition, type f as OutputType, type g as PluginContext, type T as Toolbox, type V as VERBOSITY_LEVEL } from "./packem_shared/plugin-manager.d-Dz-wu1tI.js";
3
+ export { V as VisulimaError } from "./packem_shared/index.d-Br8HpP0A.js";
4
+ import '@visulima/tabular';
5
+ type CliOptions<T extends Console = Console> = {
6
+ argv?: ReadonlyArray<string>;
7
+ cwd?: string;
8
+ logger?: T;
9
+ packageName?: string;
10
+ packageVersion?: string;
11
+ };
12
+ declare class Cli<T extends Console = Console> implements Cli$1<T> {
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: CommandSection): this;
40
+ /**
41
+ * Gets the current command section configuration.
42
+ * @returns The command section configuration
43
+ */
44
+ getCommandSection(): CommandSection;
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: Command<OD, T>): this;
92
+ /**
93
+ * Adds a global option available to all commands.
94
+ *
95
+ * Global options are parsed alongside command-specific options and displayed
96
+ * in the help output under the "Global Options" section.
97
+ * @param option The option definition
98
+ * @returns The CLI instance for method chaining
99
+ * @example
100
+ * ```typescript
101
+ * cli.addGlobalOption({
102
+ * name: 'cwd',
103
+ * type: String,
104
+ * description: 'Override working directory',
105
+ * });
106
+ * ```
107
+ */
108
+ addGlobalOption<V = unknown>(option: OptionDefinition<V>): this;
109
+ /**
110
+ * Gets all global options (built-in + custom).
111
+ * @returns Array of all global option definitions
112
+ */
113
+ getGlobalOptions(): OptionDefinition<unknown>[];
114
+ /**
115
+ * Adds a plugin to extend the CLI functionality.
116
+ *
117
+ * Plugins can hook into various lifecycle events and modify the toolbox
118
+ * to provide additional functionality to commands.
119
+ * @param plugin The plugin to register
120
+ * @returns The CLI instance for method chaining
121
+ * @example
122
+ * ```typescript
123
+ * cli.addPlugin({
124
+ * name: 'logger',
125
+ * execute: (toolbox) => {
126
+ * toolbox.logger = createCustomLogger();
127
+ * }
128
+ * });
129
+ * ```
130
+ */
131
+ addPlugin(plugin: Plugin<T>): this;
132
+ /**
133
+ * Gets the plugin manager instance for advanced plugin management.
134
+ * @returns The plugin manager instance
135
+ */
136
+ getPluginManager(): PluginManager<T>;
137
+ /**
138
+ * Gets the CLI application name.
139
+ */
140
+ getCliName(): string;
141
+ /**
142
+ * Gets the package version if configured.
143
+ * @returns The package version or undefined
144
+ */
145
+ getPackageVersion(): string | undefined;
146
+ /**
147
+ * Gets the package name if configured.
148
+ * @returns The package name or undefined
149
+ */
150
+ getPackageName(): string | undefined;
151
+ /**
152
+ * Gets all registered commands.
153
+ * @returns A map of command names to command definitions
154
+ */
155
+ getCommands(): Map<string, Command<OptionDefinition<unknown>, T>>;
156
+ /**
157
+ * Gets the current working directory.
158
+ * @returns The current working directory path
159
+ */
160
+ getCwd(): string;
161
+ /**
162
+ * Disposes the CLI instance and cleans up resources.
163
+ *
164
+ * This method removes event listeners and performs cleanup to prevent memory leaks.
165
+ * Call this method when the CLI instance is no longer needed, especially in long-running
166
+ * processes or when creating multiple CLI instances.
167
+ * @example
168
+ * ```typescript
169
+ * const cli = new Cerebro('my-app');
170
+ * // ... use the cli
171
+ * cli.dispose(); // Clean up when done
172
+ * ```
173
+ */
174
+ dispose(): void;
175
+ /**
176
+ * Runs the CLI application.
177
+ *
178
+ * This method parses command line arguments, executes the appropriate command,
179
+ * and handles the complete CLI lifecycle including plugin initialization,
180
+ * error handling, process termination, and automatic cleanup.
181
+ * @param extraOptions Additional options to pass to commands
182
+ * @param extraOptions.shouldExitProcess Whether to exit the process after execution (default: true)
183
+ * @param extraOptions.autoDispose Whether to automatically cleanup/dispose resources after execution (default: true)
184
+ * @returns A promise that resolves when execution completes
185
+ * @throws {CommandNotFoundError} If the specified command doesn't exist
186
+ * @throws {Error} If command arguments are invalid or conflicting options are provided
187
+ * @example
188
+ * ```typescript
189
+ * // Run with default behavior (exits process and auto-disposes)
190
+ * await cli.run();
191
+ *
192
+ * // Run without exiting (for testing)
193
+ * await cli.run({ shouldExitProcess: false });
194
+ *
195
+ * // Run without auto-disposing (for reuse)
196
+ * await cli.run({ autoDispose: false });
197
+ * ```
198
+ */
199
+ run(extraOptions?: CliRunOptions): Promise<void>;
200
+ /**
201
+ * Runs a command programmatically from within another command.
202
+ *
203
+ * This method allows commands to call other commands during execution,
204
+ * enabling composition of commands and reusable command logic.
205
+ * @param commandName The name of the command to execute
206
+ * @param options Optional options including argv and other command options
207
+ * @returns A promise that resolves with the command's result
208
+ * @throws {CommandNotFoundError} If the specified command doesn't exist
209
+ * @throws {CerebroError} If command validation fails
210
+ * @example
211
+ * ```typescript
212
+ * cli.addCommand({
213
+ * name: 'deploy',
214
+ * execute: async ({ runtime, logger }) => {
215
+ * logger.info('Building...');
216
+ * await runtime.runCommand('build', { argv: ['--production'] });
217
+ *
218
+ * logger.info('Testing...');
219
+ * await runtime.runCommand('test', { argv: ['--coverage'] });
220
+ * }
221
+ * });
222
+ * ```
223
+ */
224
+ runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
225
+ }
226
+ /**
227
+ * Output with this verbosity won't write anything at all.
228
+ */
229
+ declare const VERBOSITY_QUIET = 16;
230
+ /**
231
+ * Output with this verbosity will write default content.
232
+ */
233
+ declare const VERBOSITY_NORMAL = 32;
234
+ /**
235
+ * Output with this verbosity will be more detailed.
236
+ */
237
+ declare const VERBOSITY_VERBOSE = 64;
238
+ /**
239
+ * Output with this verbosity will reveal internals.
240
+ */
241
+ declare const VERBOSITY_DEBUG = 128;
242
+ /**
243
+ * Helper types for creating type-safe commands with autocomplete support.
244
+ * These types help you define your options and environment variables with full TypeScript autocomplete.
245
+ * Use these types to create type-safe Toolbox interfaces for your commands.
246
+ * @example
247
+ * ```typescript
248
+ * import { CreateOptions, CreateEnv, type Toolbox } from '@visulima/cerebro';
249
+ *
250
+ * // Define options with their original names (they'll be converted to camelCase)
251
+ * type BuildOptions = CreateOptions<{
252
+ * "output-dir": string | undefined;
253
+ * "verbose": boolean | undefined;
254
+ * "port": number | undefined;
255
+ * }>;
256
+ * // Result: { outputDir: string | undefined, verbose: boolean | undefined, port: number | undefined }
257
+ *
258
+ * // Define environment variables (UPPER_SNAKE_CASE -> camelCase)
259
+ * type BuildEnv = CreateEnv<{
260
+ * "API_KEY": string | undefined;
261
+ * "DEBUG": boolean | undefined;
262
+ * }>;
263
+ * // Result: { apiKey: string | undefined, debug: boolean | undefined }
264
+ *
265
+ * // Use in your command
266
+ * cli.addCommand({
267
+ * name: "build",
268
+ * options: [
269
+ * { name: "output-dir", type: String },
270
+ * { name: "verbose", type: Boolean },
271
+ * { name: "port", type: Number }
272
+ * ],
273
+ * env: [
274
+ * { name: "API_KEY", type: String },
275
+ * { name: "DEBUG", type: Boolean }
276
+ * ],
277
+ * execute: ({ options, env }: Toolbox<Console, BuildOptions, BuildEnv>) => {
278
+ * // Full autocomplete on options.outputDir, options.verbose, env.apiKey, etc.
279
+ * console.log(options.outputDir, options.verbose, env.apiKey);
280
+ * }
281
+ * });
282
+ * ```
283
+ */
284
+ /**
285
+ * Converts option names to camelCase for the options object.
286
+ * Options like "output-dir" become "outputDir" in the toolbox.
287
+ * @example
288
+ * ```typescript
289
+ * // Option name: "output-dir" -> options.outputDir
290
+ * // Option name: "api_key" -> options.apiKey
291
+ * // Option name: "verbose" -> options.verbose
292
+ * ```
293
+ */
294
+ type OptionNameToCamelCase<T extends string> = T extends `${infer Start}-${infer Rest}` ? `${Lowercase<Start>}${Capitalize<OptionNameToCamelCase<Rest>>}` : T extends `${infer Start}_${infer Rest}` ? `${Lowercase<Start>}${Capitalize<OptionNameToCamelCase<Rest>>}` : Lowercase<T>;
295
+ /**
296
+ * Helper type to create a type-safe options object from option definitions.
297
+ * @example
298
+ * ```typescript
299
+ * type MyOptions = CreateOptions<{
300
+ * "output-dir": string | undefined;
301
+ * "verbose": boolean | undefined;
302
+ * "port": number | undefined;
303
+ * }>;
304
+ * // Result: { outputDir: string | undefined, verbose: boolean | undefined, port: number | undefined }
305
+ * ```
306
+ */
307
+ type CreateOptions<T extends Record<string, unknown>> = { [K in keyof T as OptionNameToCamelCase<K & string>]: T[K] };
308
+ /**
309
+ * Helper type to create a type-safe environment variables object from env definitions.
310
+ * Environment variable names are converted from UPPER_SNAKE_CASE to camelCase.
311
+ * @example
312
+ * ```typescript
313
+ * type MyEnv = CreateEnv<{
314
+ * "API_KEY": string | undefined;
315
+ * "DEBUG": boolean | undefined;
316
+ * }>;
317
+ * // Result: { apiKey: string | undefined, debug: boolean | undefined }
318
+ * ```
319
+ */
320
+ type CreateEnv<T extends Record<string, unknown>> = { [K in keyof T as OptionNameToCamelCase<K & string>]: T[K] };
321
+ /**
322
+ * Builds a `loader` for commands whose handler lives as a named export in a
323
+ * shared handler module (the typical pattern when one file holds multiple
324
+ * subcommands' execute functions).
325
+ * @example
326
+ * ```ts
327
+ * // commands/cache/handler.ts
328
+ * export const cacheListExecute: CommandExecute<Toolbox> = async (toolbox) => { ... };
329
+ * export const cacheCleanExecute: CommandExecute<Toolbox> = async (toolbox) => { ... };
330
+ *
331
+ * // commands/cache/index.ts
332
+ * cli.addCommand({
333
+ * name: "list",
334
+ * loader: lazyNamed(() => import("./handler"), "cacheListExecute"),
335
+ * });
336
+ * ```
337
+ */
338
+ declare const lazyNamed: <M extends Record<string, unknown>, K extends keyof M, TContext>(load: () => Promise<M>, key: K) => (() => Promise<LazyCommandModule<TContext>>);
3
339
  declare global {
4
- namespace Cerebro {
5
- /**
6
- * Extend this interface to add custom properties to the Toolbox.
7
- * This allows plugins and extensions to add type-safe properties to the toolbox.
8
- * @example
9
- * ```typescript
10
- * declare global {
11
- * namespace Cerebro {
12
- * interface ExtensionOverrides {
13
- * // Add custom properties with full type safety
14
- * fs: {
15
- * readFile: (path: string) => Promise<string>;
16
- * writeFile: (path: string, content: string) => Promise<void>;
17
- * };
18
- * http: {
19
- * get: <T>(url: string) => Promise<T>;
20
- * post: <T>(url: string, data: unknown) => Promise<T>;
21
- * };
22
- * myCustomUtil: () => void;
23
- * }
24
- * }
25
- * }
26
- *
27
- * // Now in your commands, you get full autocomplete:
28
- * cli.addCommand({
29
- * name: "example",
30
- * execute: ({ fs, http, myCustomUtil }) => {
31
- * // ✅ Full autocomplete and type safety!
32
- * const content = await fs.readFile("file.txt");
33
- * const data = await http.get<MyType>("https://api.example.com");
34
- * myCustomUtil();
35
- * }
36
- * });
37
- * ```
38
- */
39
- interface ExtensionOverrides {
40
- }
41
- }
340
+ namespace Cerebro {
341
+ /**
342
+ * Extend this interface to add custom properties to the Toolbox.
343
+ * This allows plugins and extensions to add type-safe properties to the toolbox.
344
+ * @example
345
+ * ```typescript
346
+ * declare global {
347
+ * namespace Cerebro {
348
+ * interface ExtensionOverrides {
349
+ * // Add custom properties with full type safety
350
+ * fs: {
351
+ * readFile: (path: string) => Promise<string>;
352
+ * writeFile: (path: string, content: string) => Promise<void>;
353
+ * };
354
+ * http: {
355
+ * get: <T>(url: string) => Promise<T>;
356
+ * post: <T>(url: string, data: unknown) => Promise<T>;
357
+ * };
358
+ * myCustomUtil: () => void;
359
+ * }
360
+ * }
361
+ * }
362
+ *
363
+ * // Now in your commands, you get full autocomplete:
364
+ * cli.addCommand({
365
+ * name: "example",
366
+ * execute: ({ fs, http, myCustomUtil }) => {
367
+ * // ✅ Full autocomplete and type safety!
368
+ * const content = await fs.readFile("file.txt");
369
+ * const data = await http.get<MyType>("https://api.example.com");
370
+ * myCustomUtil();
371
+ * }
372
+ * });
373
+ * ```
374
+ */
375
+ export interface ExtensionOverrides {}
376
+ }
42
377
  }
43
378
  /**
44
- * Main entry point for the Cerebro CLI framework.
45
- *
46
- * This module provides a lightweight, extensible CLI framework for building command-line applications.
47
- * It supports plugins, subcommands, argument parsing, help generation, and more.
48
- * @example
49
- * ```typescript
50
- * import { createCerebro } from '@visulima/cerebro';
51
- *
52
- * const cli = createCerebro('my-app', {
53
- * packageName: 'my-app',
54
- * packageVersion: '1.0.0'
55
- * });
56
- *
57
- * cli.addCommand({
58
- * name: 'greet',
59
- * description: 'Greet someone',
60
- * argument: {
61
- * name: 'name',
62
- * description: 'Name to greet',
63
- * type: String
64
- * },
65
- * execute: ({ argument }) => {
66
- * console.log(`Hello, ${argument[0]}!`);
67
- * }
68
- * });
69
- *
70
- * cli.run();
71
- * ```
72
- */
73
- export type { CliOptions } from './cli.d.ts';
74
- export { Cli as Cerebro } from './cli.d.ts';
75
- export { VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE } from './constants.d.ts';
76
- export type { Cli, CliRunOptions, OutputType, RunCommandOptions, VERBOSITY_LEVEL } from './types/cli.d.ts';
77
- export type { ArgumentDefinition, Command, EnvDefinition, OptionDefinition } from './types/command.d.ts';
78
- export type { CreateEnv, CreateOptions, OptionNameToCamelCase } from './types/option-types.d.ts';
79
- export type { Plugin, PluginContext } from './types/plugin.d.ts';
80
- export type { Toolbox } from './types/toolbox.d.ts';
81
- export { VisulimaError } from "@visulima/error";
379
+ * Main entry point for the Cerebro CLI framework.
380
+ *
381
+ * This module provides a lightweight, extensible CLI framework for building command-line applications.
382
+ * It supports plugins, subcommands, argument parsing, help generation, and more.
383
+ * @example
384
+ * ```typescript
385
+ * import { createCerebro } from '@visulima/cerebro';
386
+ *
387
+ * const cli = createCerebro('my-app', {
388
+ * packageName: 'my-app',
389
+ * packageVersion: '1.0.0'
390
+ * });
391
+ *
392
+ * cli.addCommand({
393
+ * name: 'greet',
394
+ * description: 'Greet someone',
395
+ * argument: {
396
+ * name: 'name',
397
+ * description: 'Name to greet',
398
+ * type: String
399
+ * },
400
+ * execute: ({ argument }) => {
401
+ * console.log(`Hello, ${argument[0]}!`);
402
+ * }
403
+ * });
404
+ *
405
+ * cli.run();
406
+ * ```
407
+ */
82
408
  /**
83
- * Creates a new Cerebro CLI instance.
84
- *
85
- * This is the main factory function for creating CLI applications with Cerebro.
86
- * The returned CLI instance can be configured with commands, plugins, and options.
87
- * @template T - The console type (defaults to Console)
88
- * @param name The name of the CLI application
89
- * @param options Configuration options for the CLI
90
- * @returns A configured Cerebro CLI instance
91
- * @example
92
- * ```typescript
93
- * const cli = createCerebro('my-app', {
94
- * packageName: 'my-app',
95
- * packageVersion: '1.0.0'
96
- * });
97
- * ```
98
- */
99
- export declare const createCerebro: <T extends Console = Console>(name: string, options?: CliOptions<T>) => InstanceType<typeof Cli<T>>;
409
+ * Creates a new Cerebro CLI instance.
410
+ *
411
+ * This is the main factory function for creating CLI applications with Cerebro.
412
+ * The returned CLI instance can be configured with commands, plugins, and options.
413
+ * @template T - The console type (defaults to Console)
414
+ * @param name The name of the CLI application
415
+ * @param options Configuration options for the CLI
416
+ * @returns A configured Cerebro CLI instance
417
+ * @example
418
+ * ```typescript
419
+ * const cli = createCerebro('my-app', {
420
+ * packageName: 'my-app',
421
+ * packageVersion: '1.0.0'
422
+ * });
423
+ * ```
424
+ */
425
+ declare const createCerebro: <T extends Console = Console>(name: string, options?: CliOptions<T>) => InstanceType<typeof Cli<T>>;
426
+ export { Cli as Cerebro, type Cli$1 as Cli, type CliOptions, type CliRunOptions, type Command, type CreateEnv, type CreateOptions, type LazyCommandModule, type OptionDefinition, type OptionNameToCamelCase, type Plugin, type RunCommandOptions, VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE, createCerebro, lazyNamed };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var t=Object.defineProperty;var o=(r,e)=>t(r,"name",{value:e,configurable:!0});import{Cli as a}from"./packem_shared/Cerebro-aPZjbfzf.js";import{VERBOSITY_DEBUG as V,VERBOSITY_NORMAL as b,VERBOSITY_QUIET as c,VERBOSITY_VERBOSE as f}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{p as I}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,O=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const p=O((r,e)=>new a(r,e),"createCerebro");export{a as Cerebro,V as VERBOSITY_DEBUG,b as VERBOSITY_NORMAL,c as VERBOSITY_QUIET,f as VERBOSITY_VERBOSE,I as VisulimaError,p as createCerebro};
1
+ var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{Cli as t}from"./packem_shared/Cerebro-DVWKQlmP.js";import{VERBOSITY_DEBUG as R,VERBOSITY_NORMAL as V,VERBOSITY_QUIET as b,VERBOSITY_VERBOSE as c}from"./packem_shared/VERBOSITY_QUIET-XPultrIA.js";import{lazyNamed as n}from"./packem_shared/lazyNamed-DOmefeJM.js";import{p as S}from"./packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js";var E=Object.defineProperty,m=o((r,e)=>E(r,"name",{value:e,configurable:!0}),"t");const f=m((r,e)=>new t(r,e),"createCerebro");export{t as Cerebro,R as VERBOSITY_DEBUG,V as VERBOSITY_NORMAL,b as VERBOSITY_QUIET,c as VERBOSITY_VERBOSE,S as VisulimaError,f as createCerebro,n as lazyNamed};