@visulima/cerebro 3.0.0-alpha.27 → 3.0.0-alpha.28

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 CHANGED
@@ -190,10 +190,13 @@ When your command's `execute` function is called, it receives a toolbox object w
190
190
 
191
191
  ### Core Properties
192
192
 
193
- - **`logger`**: Logger instance for output (debug, info, warn, error)
193
+ - **`logger`**: Logger instance for output (debug, info, warn, error). Verbosity-gated via `--quiet`/`--verbose`/`--debug`.
194
+ - **`console`**: Alias for `logger`. Use it when porting goke-style code or when a `console`-named parameter reads more naturally.
194
195
  - **`options`**: Parsed command-line options (camelCase keys)
195
196
  - **`argument`**: Array of positional arguments
196
- - **`env`**: Environment variables (camelCase keys)
197
+ - **`env`**: Environment variables (camelCase keys) processed from the command's `env: [...]` definitions
198
+ - **`fs`**: Injected filesystem adapter (subset of `node:fs/promises`). Swap via `CliOptions.fs` for tests or sandboxed runtimes.
199
+ - **`process`**: Runtime snapshot — `cwd`, `env`, `argv`, `stdin`, `exit`, `platform`, `arch`. Prefer this over the global `process` so commands stay portable across Node, Deno, Bun, and mocked test runtimes.
197
200
  - **`runtime`**: Reference to the CLI instance
198
201
  - **`argv`**: Original command-line arguments array
199
202
 
@@ -241,6 +244,127 @@ cli.addCommand({
241
244
  });
242
245
  ```
243
246
 
247
+ ## Runtime Injection
248
+
249
+ Commands receive an injected `{ fs, console, process }` context on the toolbox. Prefer reading from these over reaching for `node:fs/promises`, the global `console`, or the global `process` — commands written against the injected context stay testable, portable across Node/Deno/Bun, and ready to run inside sandboxed environments like MCP servers.
250
+
251
+ ```ts
252
+ import { Cerebro } from "@visulima/cerebro";
253
+
254
+ const cli = new Cerebro("acme");
255
+
256
+ cli.addCommand({
257
+ name: "login",
258
+ description: "Save an auth token",
259
+ options: [{ name: "token", type: String, description: "API token" }],
260
+ execute: async ({ fs, console, process, options }) => {
261
+ await fs.mkdir(".acme", { recursive: true });
262
+ await fs.writeFile(".acme/auth.json", JSON.stringify({ token: options.token }), "utf8");
263
+ console.log("saved credentials in", process.cwd);
264
+ },
265
+ });
266
+
267
+ await cli.run();
268
+ ```
269
+
270
+ ### Overriding the runtime
271
+
272
+ Pass any of the new `CliOptions` to swap the runtime context. Each override defaults to a sensible host value:
273
+
274
+ | Option | Default | Used for |
275
+ | -------- | ---------------------------- | --------------------------------------------------------- |
276
+ | `fs` | `node:fs/promises` adapter | Filesystem operations from `toolbox.fs` |
277
+ | `exit` | Runtime-agnostic exit helper | `toolbox.process.exit` |
278
+ | `env` | Host `process.env` | `toolbox.process.env` (does **not** affect `toolbox.env`) |
279
+ | `stdin` | `""` (empty string) | `toolbox.process.stdin` |
280
+ | `cwd` | Runtime cwd | `toolbox.process.cwd` |
281
+ | `logger` | Verbosity-aware console shim | `toolbox.logger` and `toolbox.console` |
282
+
283
+ ```ts
284
+ const exitSpy = vi.fn();
285
+ const fakeFs = new InMemoryFs();
286
+
287
+ const cli = new Cerebro("acme", {
288
+ cwd: "/virtual/project",
289
+ fs: fakeFs,
290
+ exit: exitSpy,
291
+ env: { NODE_ENV: "test" },
292
+ stdin: "y\n",
293
+ });
294
+ ```
295
+
296
+ ### Testing with mocked runtime
297
+
298
+ The runtime overrides remove the need for `vi.spyOn(process, "exit")` or `vi.spyOn(console, "log")` in command tests. Pass mocks at CLI construction; assert on them directly.
299
+
300
+ ```ts
301
+ import { describe, expect, test, vi } from "vitest";
302
+ import { Cerebro } from "@visulima/cerebro";
303
+
304
+ describe("deploy command", () => {
305
+ test("exits with code 2 when env is missing", async () => {
306
+ const exit = vi.fn();
307
+ const calls: string[] = [];
308
+ const logger = {
309
+ log: (...args: unknown[]) => calls.push(String(args[0])),
310
+ info: () => {},
311
+ warn: () => {},
312
+ error: () => {},
313
+ debug: () => {},
314
+ };
315
+
316
+ const cli = new Cerebro("acme", { argv: ["deploy"], exit, logger });
317
+ cli.addCommand({
318
+ name: "deploy",
319
+ execute: ({ console, process, options }) => {
320
+ if (!options.env) {
321
+ console.log("missing --env");
322
+ process.exit(2);
323
+ }
324
+ },
325
+ });
326
+
327
+ await cli.run({ shouldExitProcess: false });
328
+
329
+ expect(exit).toHaveBeenCalledWith(2);
330
+ expect(calls).toStrictEqual(["missing --env"]);
331
+ });
332
+ });
333
+ ```
334
+
335
+ ### `cli.clone(options?)`
336
+
337
+ Creates an independent CLI sharing the same command definitions. The clone has its own commands map, global options, default-command setting, and plugin manager — so adding commands or changing options on the clone never mutates the original. Primarily useful in tests to run the same CLI with different `argv`/`exit`/`fs` overrides without rebuilding the command tree.
338
+
339
+ ```ts
340
+ const cli = new Cerebro("acme");
341
+ cli.addCommand({ name: "build", execute: ({ console }) => console.log("building") });
342
+
343
+ // In tests: clone with mocked exit + captured argv
344
+ const isolatedExit = vi.fn();
345
+ const isolated = cli.clone({ argv: ["build"], exit: isolatedExit });
346
+ await isolated.run({ shouldExitProcess: false });
347
+ ```
348
+
349
+ ### `cli.getAction(commandName)`
350
+
351
+ Returns the resolved `execute` function for a registered command. For lazy commands defined with `loader`, the module is loaded once and cached. Supports space-separated nested command paths.
352
+
353
+ ```ts
354
+ const cli = new Cerebro("acme");
355
+
356
+ cli.addCommand({
357
+ name: "deploy",
358
+ execute: ({ console, options }) => console.log("deploying to", options.env),
359
+ });
360
+
361
+ // Call the action directly with a synthesized toolbox — no argv parsing.
362
+ const action = await cli.getAction("deploy");
363
+ await action({ console: fakeConsole, options: { env: "staging" } } as never);
364
+ ```
365
+
366
+ Use this when you want to unit-test a command action in isolation without going through `run()`'s full lifecycle (plugin init, exception handlers, exit). For end-to-end tests that exercise argv parsing and lifecycle hooks, prefer `cli.clone(...).run(...)` instead.
367
+
244
368
  ## Built-in Commands
245
369
 
246
370
  Cerebro comes with several built-in commands that are automatically available:
@@ -1,4 +1,4 @@
1
- import { C as Command } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
1
+ import { C as Command } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
2
2
  import '@visulima/tabular';
3
3
  /**
4
4
  * Generates shell completion scripts for the CLI application.
@@ -1,4 +1,4 @@
1
- import { O as OptionDefinition, A as ArgumentDefinition, C as Command, T as Toolbox } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
1
+ import { O as OptionDefinition, A as ArgumentDefinition, C as Command, T as Toolbox } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
2
2
  import '@visulima/tabular';
3
3
  declare class HelpCommand<TLogger extends Console = Console> implements Command<OptionDefinition<string>, TLogger> {
4
4
  argument: ArgumentDefinition<string>;
@@ -1 +1 @@
1
- var E=Object.defineProperty;var b=(a,o)=>E(a,"name",{value:o,configurable:!0});import{green as h,inverse as p,cyan as g,yellow as f}from"@visulima/colorize";import{f as v,p as y}from"../packem_shared/index-DZdxQ8Yb.js";const N=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}];var w=Object.defineProperty,u=b((a,o)=>w(a,"name",{value:o,configurable:!0}),"f");const $="__Other",C=u(a=>a.charAt(0).toUpperCase()+a.slice(1),"upperFirstChar"),A=u((a,o,l,i)=>{a.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(n=>!n.hidden);i&&(m=m.filter(n=>n.group===i));const e=m.reduce((n,s)=>{const d=s.group??$;return n[d]??=[],n[d].push(s),n},{}),r=u(n=>n.map(s=>{let d="";typeof s.alias=="string"?d=s.alias:Array.isArray(s.alias)&&(d=s.alias.join(", ")),d!==""&&(d=` [${d}]`);let t=s.name;return s.commandPath&&s.commandPath.length>0&&(t=`${s.commandPath.join(" ")} ${s.name}`),[`${h(t)}${d}`,s.description??""]}),"buildCommandList");(a.raw??a.log)(y([{content:`${g(o.getCliName())} ${h("<command>")} [positional arguments] ${f("[options]")}`,header:p.cyan(" Usage ")},...Object.keys(e).map(n=>{const s=i?` ${C(i)}`:"";return{content:r(e[n]),header:n===$||i?p.green(` Available${s} Commands `):` ${p.green(` ${C(n)} `)}`}}),l.has("help")?{header:p.yellow(" Command Options "),optionList:l.get("help").options?.filter(n=>!n.hidden)}:void 0,{header:p.yellow(" Global Options "),optionList:o.getGlobalOptions()},{content:N.filter(n=>!n.hidden).map(n=>[n.name,n.description??""]),header:p.magenta(" Environment Variables ")},{content:`Run "${g(o.getCliName())} ${h("help <command>")}" or "${g(o.getCliName())} ${h("<command>")} ${f("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),O=u((a,o)=>{const l=[];for(const i of a.values()){if(i.hidden)continue;const m=i.commandPath??[];if(m.length!==o.length)continue;let e=!0;for(const[r,n]of o.entries())if(m[r]!==n){e=!1;break}e&&l.push(i)}return l},"findChildren"),P=u((a,o,l,i)=>{const m=l.join(" "),e=[{content:`${g(o.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${f("[options]")}`,header:p.cyan(" Usage ")},{content:i.map(r=>{const n=[...r.commandPath??[],r.name].join(" ");return[h(n),r.description??""]}),header:p.green(" Subcommands ")},{header:p.yellow(" Global Options "),optionList:o.getGlobalOptions()},{content:`Run "${g(o.getCliName())} ${h(`${m} <subcommand>`)} ${f("--help")}" for help with a specific subcommand.`,raw:!0}];(a.raw??a.log)(y(e))},"printParentHelp"),j=u((a,o,l,i,m)=>{let e=m??l.get(i);if(!e)for(const t of l.values()){const c=t.commandPath?[...t.commandPath,t.name]:[t.name];if(c.at(-1)===i||c.join(" ")===i){e=t;break}}if(!e){const t=i.split(" ").filter(Boolean),c=t.length>0?O(l,t):[];if(c.length>0){P(a,o,t,c);return}a.error(`Command "${i}" not found`);return}const r=[],n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(r.push({content:`${g(o.getCliName())} ${h(n)}${e.argument?" [positional arguments]":""}${e.options?" [options]":""}`,header:p.cyan(" Usage ")}),e.description&&r.push({content:e.description,header:p.green(" Description ")}),e.argument&&r.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&r.push({header:p.yellow(" Command Options "),optionList:e.options.filter(t=>!t.hidden)}),r.push({header:p.yellow(" Global Options "),optionList:o.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const t=e.env.filter(c=>!c.hidden);t.length>0&&r.push({content:t.map(c=>[c.name,c.description??""]),header:p.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let t=e.alias;typeof e.alias=="string"&&(t=[e.alias]),r.splice(1,0,{content:t,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&r.push({content:e.examples,header:"Examples"});const s=[...e.commandPath??[],e.name],d=O(l,s);d.length>0&&r.push({content:d.map(t=>{const c=[...t.commandPath??[],t.name].join(" ");return[h(c),t.description??""]}),header:p.green(" Subcommands ")}),(a.raw??a.log)(y(r))},"printCommandHelp");class L{static{b(this,"x")}static{u(this,"HelpCommand")}argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(o){this.commands=o}execute(o){const{argument:l,command:i,commandName:m,logger:e,options:r,runtime:n}=o,{footer:s,header:d}=n.getCommandSection();d&&(e.raw??e.log)(v(d));const t=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&t===void 0)A(e,n,this.commands,typeof r?.group=="string"?r.group:void 0);else{const c=t!==void 0||i===void 0||i.name==="help"?void 0:i;j(e,n,this.commands,t??m,c)}s&&(e.raw??e.log)(v(s))}}export{L as default};
1
+ var E=Object.defineProperty;var b=(a,o)=>E(a,"name",{value:o,configurable:!0});import{green as h,inverse as p,cyan as g,yellow as f}from"@visulima/colorize";import{f as v,p as y}from"../packem_shared/index-Bl6FHt1Y.js";const N=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}];var w=Object.defineProperty,u=b((a,o)=>w(a,"name",{value:o,configurable:!0}),"f");const $="__Other",C=u(a=>a.charAt(0).toUpperCase()+a.slice(1),"upperFirstChar"),A=u((a,o,l,i)=>{a.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(n=>!n.hidden);i&&(m=m.filter(n=>n.group===i));const e=m.reduce((n,s)=>{const d=s.group??$;return n[d]??=[],n[d].push(s),n},{}),r=u(n=>n.map(s=>{let d="";typeof s.alias=="string"?d=s.alias:Array.isArray(s.alias)&&(d=s.alias.join(", ")),d!==""&&(d=` [${d}]`);let t=s.name;return s.commandPath&&s.commandPath.length>0&&(t=`${s.commandPath.join(" ")} ${s.name}`),[`${h(t)}${d}`,s.description??""]}),"buildCommandList");(a.raw??a.log)(y([{content:`${g(o.getCliName())} ${h("<command>")} [positional arguments] ${f("[options]")}`,header:p.cyan(" Usage ")},...Object.keys(e).map(n=>{const s=i?` ${C(i)}`:"";return{content:r(e[n]),header:n===$||i?p.green(` Available${s} Commands `):` ${p.green(` ${C(n)} `)}`}}),l.has("help")?{header:p.yellow(" Command Options "),optionList:l.get("help").options?.filter(n=>!n.hidden)}:void 0,{header:p.yellow(" Global Options "),optionList:o.getGlobalOptions()},{content:N.filter(n=>!n.hidden).map(n=>[n.name,n.description??""]),header:p.magenta(" Environment Variables ")},{content:`Run "${g(o.getCliName())} ${h("help <command>")}" or "${g(o.getCliName())} ${h("<command>")} ${f("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),O=u((a,o)=>{const l=[];for(const i of a.values()){if(i.hidden)continue;const m=i.commandPath??[];if(m.length!==o.length)continue;let e=!0;for(const[r,n]of o.entries())if(m[r]!==n){e=!1;break}e&&l.push(i)}return l},"findChildren"),P=u((a,o,l,i)=>{const m=l.join(" "),e=[{content:`${g(o.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${f("[options]")}`,header:p.cyan(" Usage ")},{content:i.map(r=>{const n=[...r.commandPath??[],r.name].join(" ");return[h(n),r.description??""]}),header:p.green(" Subcommands ")},{header:p.yellow(" Global Options "),optionList:o.getGlobalOptions()},{content:`Run "${g(o.getCliName())} ${h(`${m} <subcommand>`)} ${f("--help")}" for help with a specific subcommand.`,raw:!0}];(a.raw??a.log)(y(e))},"printParentHelp"),j=u((a,o,l,i,m)=>{let e=m??l.get(i);if(!e)for(const t of l.values()){const c=t.commandPath?[...t.commandPath,t.name]:[t.name];if(c.at(-1)===i||c.join(" ")===i){e=t;break}}if(!e){const t=i.split(" ").filter(Boolean),c=t.length>0?O(l,t):[];if(c.length>0){P(a,o,t,c);return}a.error(`Command "${i}" not found`);return}const r=[],n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(r.push({content:`${g(o.getCliName())} ${h(n)}${e.argument?" [positional arguments]":""}${e.options?" [options]":""}`,header:p.cyan(" Usage ")}),e.description&&r.push({content:e.description,header:p.green(" Description ")}),e.argument&&r.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&r.push({header:p.yellow(" Command Options "),optionList:e.options.filter(t=>!t.hidden)}),r.push({header:p.yellow(" Global Options "),optionList:o.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const t=e.env.filter(c=>!c.hidden);t.length>0&&r.push({content:t.map(c=>[c.name,c.description??""]),header:p.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let t=e.alias;typeof e.alias=="string"&&(t=[e.alias]),r.splice(1,0,{content:t,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&r.push({content:e.examples,header:"Examples"});const s=[...e.commandPath??[],e.name],d=O(l,s);d.length>0&&r.push({content:d.map(t=>{const c=[...t.commandPath??[],t.name].join(" ");return[h(c),t.description??""]}),header:p.green(" Subcommands ")}),(a.raw??a.log)(y(r))},"printCommandHelp");class L{static{b(this,"x")}static{u(this,"HelpCommand")}argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(o){this.commands=o}execute(o){const{argument:l,command:i,commandName:m,logger:e,options:r,runtime:n}=o,{footer:s,header:d}=n.getCommandSection();d&&(e.raw??e.log)(v(d));const t=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&t===void 0)A(e,n,this.commands,typeof r?.group=="string"?r.group:void 0);else{const c=t!==void 0||i===void 0||i.name==="help"?void 0:i;j(e,n,this.commands,t??m,c)}s&&(e.raw??e.log)(v(s))}}export{L as default};
@@ -1,4 +1,4 @@
1
- import { C as Command } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
1
+ import { C as Command } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
2
2
  import '@visulima/tabular';
3
3
  /**
4
4
  * Generates README documentation for cerebro CLI commands.
@@ -1,4 +1,4 @@
1
- var O=Object.defineProperty;var f=(e,t)=>O(e,"name",{value:t,configurable:!0});import{createRequire as L}from"node:module";import U from"github-slugger";import{p as G}from"../packem_shared/index-DZdxQ8Yb.js";import{g as F,a as M,b as W,c as z}from"../packem_shared/runtime-process-DKHFvYkv.js";const N=L(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=f(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,n]=g.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return g.getBuiltinModule(e)}return N(e)},"__cjs_getBuiltinModule"),{existsSync:v}=A("node:fs"),{readFile:T,mkdir:k,writeFile:B}=A("node:fs/promises"),{resolve:P,join:V,dirname:q}=A("node:path");var H=Object.defineProperty,c=f((e,t)=>H(e,"name",{value:t,configurable:!0}),"m");const I=new U,C=c(e=>I.slug(e),"slugify"),J=c(e=>e.filter(Boolean),"compact"),K=c((e,t)=>{const n=new Set,o=[];for(const r of e){const i=t(r);n.has(i)||(n.add(i),o.push(r))}return o},"uniqBy"),D=c((e,t)=>{const n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const o=e.argument.name.toUpperCase(),r=e.argument.required?o:`[${o}]`;return`${t} ${n} ${r}`}return`${t} ${n}`},"formatCommandUsage"),Q=c((e,t)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const n=e.env.filter(o=>!o.hidden);n.length>0&&t.push({content:n.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},"addEnvironmentVariables"),X=c((e,t)=>{const n=[],o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,i=!!e.options;if(n.push({content:`${t} ${o}${r?" [positional arguments]":""}${i?" [options]":""}`,header:" Usage "}),e.description&&n.push({content:e.description,header:" Description "}),e.argument&&n.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&n.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),Q(e,n),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];n.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&n.push({content:e.examples,header:"Examples"}),G(n)},"formatCommandHelp"),Y=c((e,t)=>{const n=e.description?.trim().split(`
1
+ var O=Object.defineProperty;var f=(e,t)=>O(e,"name",{value:t,configurable:!0});import{createRequire as L}from"node:module";import U from"github-slugger";import{p as G}from"../packem_shared/index-Bl6FHt1Y.js";import{g as F,a as M,b as W,c as z}from"../packem_shared/runtime-process-DKHFvYkv.js";const N=L(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=f(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,n]=g.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return g.getBuiltinModule(e)}return N(e)},"__cjs_getBuiltinModule"),{existsSync:v}=A("node:fs"),{readFile:T,mkdir:k,writeFile:B}=A("node:fs/promises"),{resolve:P,join:V,dirname:q}=A("node:path");var H=Object.defineProperty,c=f((e,t)=>H(e,"name",{value:t,configurable:!0}),"m");const I=new U,C=c(e=>I.slug(e),"slugify"),J=c(e=>e.filter(Boolean),"compact"),K=c((e,t)=>{const n=new Set,o=[];for(const r of e){const i=t(r);n.has(i)||(n.add(i),o.push(r))}return o},"uniqBy"),D=c((e,t)=>{const n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const o=e.argument.name.toUpperCase(),r=e.argument.required?o:`[${o}]`;return`${t} ${n} ${r}`}return`${t} ${n}`},"formatCommandUsage"),Q=c((e,t)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const n=e.env.filter(o=>!o.hidden);n.length>0&&t.push({content:n.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},"addEnvironmentVariables"),X=c((e,t)=>{const n=[],o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,i=!!e.options;if(n.push({content:`${t} ${o}${r?" [positional arguments]":""}${i?" [options]":""}`,header:" Usage "}),e.description&&n.push({content:e.description,header:" Description "}),e.argument&&n.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&n.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),Q(e,n),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];n.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&n.push({content:e.examples,header:"Examples"}),G(n)},"formatCommandHelp"),Y=c((e,t)=>{const n=e.description?.trim().split(`
2
2
  `)[0]??"",o=D(e,t),r=X(e,t);return J([`## \`${o}\``,n,`\`\`\`
3
3
  ${r.trim()}
4
4
  \`\`\``]).join(`
@@ -1,4 +1,4 @@
1
- import { C as Command } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
1
+ import { C as Command } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
2
2
  import '@visulima/tabular';
3
3
  declare const _default: Command;
4
4
  export { _default as default };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,38 @@
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";
1
+ import { a as CerebroFs, b as CommandSection, O as OptionDefinition, C as Command, P as Plugin, c as PluginManager, d as CliRunOptions, R as RunCommandOptions, T as Toolbox, e as CommandExecute, f as Cli$1, L as LazyCommandModule } from "./packem_shared/plugin-manager.d-BSQtHbWS.js";
2
+ export { type A as ArgumentDefinition, type g as CerebroProcess, type E as EnvDefinition, type h as OutputType, type i as PluginContext, type V as VERBOSITY_LEVEL } from "./packem_shared/plugin-manager.d-BSQtHbWS.js";
3
3
  export { V as VisulimaError } from "./packem_shared/index.d-Br8HpP0A.js";
4
4
  import '@visulima/tabular';
5
5
  type CliOptions<T extends Console = Console> = {
6
6
  argv?: ReadonlyArray<string>;
7
7
  cwd?: string;
8
+ /**
9
+ * Process environment variables exposed to commands via `toolbox.process.env`.
10
+ * Defaults to the runtime's process environment. Override to provide a
11
+ * captured snapshot in tests so commands don't read mutating host state.
12
+ */
13
+ env?: Record<string, string | undefined>;
14
+ /**
15
+ * Function called when a command invokes `toolbox.process.exit(code)`.
16
+ * Defaults to the runtime-agnostic exit helper that terminates the process.
17
+ * Override with a `vi.fn()` in tests to capture exit codes without killing
18
+ * the test runner.
19
+ */
20
+ exit?: (code?: number) => void;
21
+ /**
22
+ * Filesystem adapter exposed via `toolbox.fs`. Defaults to `node:fs/promises`.
23
+ * Override with an in-memory or sandboxed adapter for tests and embedded
24
+ * runtimes (MCP, JustBash).
25
+ */
26
+ fs?: CerebroFs;
8
27
  logger?: T;
9
28
  packageName?: string;
10
29
  packageVersion?: string;
30
+ /**
31
+ * Buffered stdin content exposed via `toolbox.process.stdin`. Empty string
32
+ * by default. Useful for tests and sandboxed runtimes where wiring real
33
+ * stdin is impractical.
34
+ */
35
+ stdin?: string;
11
36
  };
12
37
  declare class Cli<T extends Console = Console> implements Cli$1<T> {
13
38
  #private;
@@ -222,6 +247,60 @@ declare class Cli<T extends Console = Console> implements Cli$1<T> {
222
247
  * ```
223
248
  */
224
249
  runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
250
+ /**
251
+ * Creates a shallow copy of the CLI with optional `CliOptions` overrides.
252
+ *
253
+ * The clone shares the underlying command definitions (the same `Command`
254
+ * objects are reused), but has its own commands map, global-options list,
255
+ * default-command setting, command-section configuration, and a freshly
256
+ * initialized plugin manager. Mutating one CLI's commands after cloning
257
+ * does not affect the other.
258
+ *
259
+ * Primarily useful in tests to run the same CLI definition with different
260
+ * argv / stdout / exit / fs overrides without rebuilding the command tree.
261
+ * @param overrides Optional `CliOptions` to merge over the clone's existing options
262
+ * @returns A new `Cli` instance with the same commands and merged options
263
+ * @example
264
+ * ```typescript
265
+ * const cli = new Cerebro("acme");
266
+ * cli.addCommand({ name: "build", execute: ({ console }) => console.log("building") });
267
+ *
268
+ * // In tests: clone with mocked exit + captured stdout
269
+ * const exitSpy = vi.fn();
270
+ * const isolated = cli.clone({ argv: ["build"], exit: exitSpy });
271
+ * await isolated.run({ shouldExitProcess: false });
272
+ * ```
273
+ */
274
+ clone(overrides?: CliOptions<T>): Cli<T>;
275
+ /**
276
+ * Returns the resolved `execute` function for a registered command.
277
+ *
278
+ * For lazy-loaded commands (defined via `loader`), the loader is awaited
279
+ * and its module's default export is returned. The result is cached on the
280
+ * command for subsequent calls. Supports space-separated nested command
281
+ * paths (e.g. `"git remote add"`).
282
+ *
283
+ * Primarily useful in tests to invoke a command's handler directly with a
284
+ * synthesized toolbox, without going through argv parsing or the full
285
+ * `run()` lifecycle.
286
+ * @param commandName The command name or space-separated nested path
287
+ * @returns A promise resolving to the command's handler function
288
+ * @throws {CommandNotFoundError} If no command matches the given name
289
+ * @throws {CerebroError} If the command has neither `execute` nor `loader`
290
+ * @example
291
+ * ```typescript
292
+ * const cli = new Cerebro("acme");
293
+ * cli.addCommand({
294
+ * name: "deploy",
295
+ * execute: ({ console, options }) => console.log("deploying to", options.env),
296
+ * });
297
+ *
298
+ * // In tests: call the action directly with a mocked toolbox
299
+ * const action = await cli.getAction("deploy");
300
+ * await action({ console: fakeConsole, options: { env: "staging" } } as never);
301
+ * ```
302
+ */
303
+ getAction(commandName: string): Promise<CommandExecute<Toolbox<T>>>;
225
304
  }
226
305
  /**
227
306
  * Output with this verbosity won't write anything at all.
@@ -423,4 +502,4 @@ declare global {
423
502
  * ```
424
503
  */
425
504
  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 };
505
+ export { Cli as Cerebro, type CerebroFs, type Cli$1 as Cli, type CliOptions, type CliRunOptions, type Command, type CommandExecute, type CreateEnv, type CreateOptions, type LazyCommandModule, type OptionDefinition, type OptionNameToCamelCase, type Plugin, type RunCommandOptions, type Toolbox, VERBOSITY_DEBUG, VERBOSITY_NORMAL, VERBOSITY_QUIET, VERBOSITY_VERBOSE, createCerebro, lazyNamed };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{Cli as t}from"./packem_shared/Cerebro-Bx5ieMPF.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};
1
+ var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{Cli as t}from"./packem_shared/Cerebro-CtfwEvsG.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};
@@ -1,43 +1,8 @@
1
1
  import { InteractiveManager } from '@visulima/interactive-manager';
2
2
  import { stringify } from 'safe-stable-stringify';
3
+ import { LiteralUnion, Primitive } from 'type-fest';
3
4
  import { AnsiColors } from '@visulima/colorize';
4
5
  /**
5
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
6
-
7
- @category Type
8
- */
9
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
10
- /**
11
- Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
12
-
13
- Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
14
-
15
- This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
16
-
17
- @example
18
- ```
19
- import type {LiteralUnion} from 'type-fest';
20
-
21
- // Before
22
-
23
- type Pet = 'dog' | 'cat' | string;
24
-
25
- const petWithoutAutocomplete: Pet = '';
26
- // Start typing in your TypeScript-enabled IDE.
27
- // You **will not** get auto-completion for `dog` and `cat` literals.
28
-
29
- // After
30
-
31
- type Pet2 = LiteralUnion<'dog' | 'cat', string>;
32
-
33
- const petWithAutoComplete: Pet2 = '';
34
- // You **will** get auto-completion for `dog` and `cat` literals.
35
- ```
36
-
37
- @category Type
38
- */
39
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
40
- /**
41
6
  * Global namespace for extending Pail's metadata interface.
42
7
  *
43
8
  * This global declaration allows other packages and applications to extend
@@ -0,0 +1,4 @@
1
+ var Rt=Object.defineProperty;var O=(t,e)=>Rt(t,"name",{value:e,configurable:!0});import{createRequire as zt}from"node:module";import{VERBOSITY_DEBUG as K,POSITIONALS_KEY as re,VERBOSITY_QUIET as Jt,VERBOSITY_VERBOSE as Qt,VERBOSITY_NORMAL as je}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as A}from"./cerebro-error-BnJTixb2.js";import{d as R,h as ke,e as Y,o as Ie,b as Xt,c as Zt,a as en,i as tn,f as nn}from"./runtime-process-DKHFvYkv.js";import{distance as an}from"fastest-levenshtein";import{s as on,L as rn,M as ee,E as te,P as G,N as L,C as ye,D as Ue,W as sn,U as Me,Q as ln,_ as Ve,J as Te,T as Se,z as cn,K as un,q as pn,I as fn,V as dn,u as hn,r as mn,Y as gn,p as vn,n as yn,Z as wn,i as bn,a as $n,A as On,X as Pn,e as An,t as De}from"./constants-DmzZF6_u-BmMwILI_.js";const Wt=zt(import.meta.url),X=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,it=O(t=>{if(typeof X<"u"&&X.versions&&X.versions.node){const[e,n]=X.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return X.getBuiltinModule(t)}return Wt(t)},"__cjs_getBuiltinModule"),{writeFile:Ft,stat:qt,rm:Gt,readFile:Le,readdir:Ht,mkdir:Kt,access:Yt}=it("node:fs/promises"),{createRequire:Cn}=it("node:module"),ae=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var Nn=Object.defineProperty,kn=O((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"t$9");let S=class extends A{static{O(this,"a")}static{kn(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const a=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(a,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}};var _n=Object.defineProperty,En=O((t,e)=>_n(t,"name",{value:e,configurable:!0}),"e$7");let at=class extends A{static{O(this,"o")}static{En(this,"ConflictingOptionsError")}option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}};var xn=Object.defineProperty,Ln=O((t,e)=>xn(t,"name",{value:e,configurable:!0}),"e$6");let jn=class extends A{static{O(this,"o")}static{Ln(this,"PluginError")}pluginName;constructor(e,n,a){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:a,pluginName:e}),this.name="PluginError",this.pluginName=e,a&&(this.cause=a)}};var In=Object.defineProperty,Be=O((t,e)=>In(t,"name",{value:e,configurable:!0}),"d$7");let Un=class{static{O(this,"p")}static{Be(this,"PluginManager")}logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);R().CEREBRO_OUTPUT_LEVEL===String(K)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const a of n)if(typeof a.init=="function"){this.logger.debug(`initializing plugin: ${a.name}`);try{await a.init(e)}catch(r){const i=new jn(a.name,`Failed to initialize: ${r instanceof Error?r.message:String(r)}`,r instanceof Error?r:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,a){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const r=this.getDependencyOrder();for(const i of r){const u=i[e];if(typeof u=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?u(n,a):u(n))}catch(s){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,s),s}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const a=this.getDependencyOrder();for(const r of a)if(typeof r.onError=="function"){this.logger.debug(`executing error handler for plugin: ${r.name}`);try{await r.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${r.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,a=new Set,r=Be(i=>{if(n.has(i))return;if(a.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const u=this.plugins.get(i);if(!u)throw new Error(`Plugin "${i}" not found`);if(a.add(i),u.dependencies)for(const s of u.dependencies)r(s);a.delete(i),n.add(i),e.push(u)},"visit");for(const i of this.plugins.keys())r(i);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};var Mn=Object.defineProperty,Vn=O((t,e)=>Mn(t,"name",{value:e,configurable:!0}),"n$a");const ne=Vn(t=>t.type?.name==="Boolean","optionIsBoolean");var Tn=Object.defineProperty,ot=O((t,e)=>Tn(t,"name",{value:e,configurable:!0}),"p$9");const Sn=ot(t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},"getTypeLabel"),Re=ot(t=>(ne(t)||(t.typeLabel=t.typeLabel??Sn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var Dn=Object.defineProperty,rt=O((t,e)=>Dn(t,"name",{value:e,configurable:!0}),"e$4");const Bn=new RegExp(/^-([^\d-])$/),Rn=new RegExp(/^--(\S+)/),zn=new RegExp(/^-([^\d-]{2,})$/),Wn=rt(t=>Bn.test(t)||Rn.test(t)||zn.test(t),"isOption"),Fn=rt((t,e)=>{const n=e[0]&&Wn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const a=new Error(`Command not recognised: ${String(n)}`);throw a.command=n,a.name="INVALID_COMMAND",a}return{argv:e,command:n}},"commandLineCommands");var qn=Object.defineProperty,st=O((t,e)=>qn(t,"name",{value:e,configurable:!0}),"i$b"),Gn=Object.defineProperty,lt=st((t,e)=>Gn(t,"name",{value:e,configurable:!0}),"i"),Hn=Object.defineProperty,ct=lt((t,e)=>Hn(t,"name",{value:e,configurable:!0}),"s"),Kn=Object.defineProperty,ut=ct((t,e)=>Kn(t,"name",{value:e,configurable:!0}),"i"),Yn=Object.defineProperty,pt=ut((t,e)=>Yn(t,"name",{value:e,configurable:!0}),"t");pt(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");let ce=class extends Error{static{O(this,"v")}static{st(this,"g")}static{lt(this,"p")}static{ct(this,"V")}static{ut(this,"VisulimaError")}static{pt(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:a,message:r,name:i,stack:u,title:s}){super(r,{cause:e}),this.title=s,this.name=i,this.stack=u??this.stack,this.loc=a,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}};var Jn=Object.defineProperty,ft=O((t,e)=>Jn(t,"name",{value:e,configurable:!0}),"o$b"),Qn=Object.defineProperty,dt=ft((t,e)=>Qn(t,"name",{value:e,configurable:!0}),"o"),Xn=Object.defineProperty,Zn=dt((t,e)=>Xn(t,"name",{value:e,configurable:!0}),"i");let ei=class ht extends ce{static{O(this,"a")}static{ft(this,"a")}static{dt(this,"t")}static{Zn(this,"AlreadySetError")}optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,ht.prototype)}};var ti=Object.defineProperty,mt=O((t,e)=>ti(t,"name",{value:e,configurable:!0}),"t$7"),ni=Object.defineProperty,gt=mt((t,e)=>ni(t,"name",{value:e,configurable:!0}),"e"),ii=Object.defineProperty,ai=gt((t,e)=>ii(t,"name",{value:e,configurable:!0}),"e");let ze=class vt extends ce{static{O(this,"n")}static{mt(this,"n")}static{gt(this,"o")}static{ai(this,"UnknownOptionError")}optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,vt.prototype)}};var oi=Object.defineProperty,yt=O((t,e)=>oi(t,"name",{value:e,configurable:!0}),"a$9"),ri=Object.defineProperty,wt=yt((t,e)=>ri(t,"name",{value:e,configurable:!0}),"a"),si=Object.defineProperty,li=wt((t,e)=>si(t,"name",{value:e,configurable:!0}),"o");let ci=class bt extends ce{static{O(this,"n")}static{yt(this,"o")}static{wt(this,"e")}static{li(this,"UnknownValueError")}value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,bt.prototype)}};var ui=Object.defineProperty,$t=O((t,e)=>ui(t,"name",{value:e,configurable:!0}),"i$8"),pi=Object.defineProperty,Ot=$t((t,e)=>pi(t,"name",{value:e,configurable:!0}),"i"),fi=Object.defineProperty,di=Ot((t,e)=>fi(t,"name",{value:e,configurable:!0}),"i");let j=class Pt extends ce{static{O(this,"a")}static{$t(this,"o")}static{Ot(this,"e")}static{di(this,"InvalidDefinitionsError")}constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,Pt.prototype)}};var hi=Object.defineProperty,mi=O((t,e)=>hi(t,"name",{value:e,configurable:!0}),"z"),gi=Object.defineProperty,J=mi((t,e)=>gi(t,"name",{value:e,configurable:!0}),"S"),vi=Object.defineProperty,ue=J((t,e)=>vi(t,"name",{value:e,configurable:!0}),"o");const We=ue(t=>t===Boolean||typeof t=="function"&&t.name.startsWith("Boolean"),"isBooleanType"),Fe=ue(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),qe=ue(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),yi=ue((t,e)=>Array.isArray(t)?We(e)?t.map(Boolean):Fe(e)?t.map(Number):qe(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:We(e)?!!t:Fe(e)?Number(t):qe(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t)),"convertValue");var wi=Object.defineProperty,bi=J((t,e)=>wi(t,"name",{value:e,configurable:!0}),"e");const x=bi((t,e,n,...a)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...a)},"debug");var $i=Object.defineProperty,F=J((t,e)=>$i(t,"name",{value:e,configurable:!0}),"h$1");const Oi=/-([a-z])/g,Pi=/^\d+$/,we=F(t=>t===Boolean||typeof t=="function"&&t.name.startsWith("Boolean"),"isBooleanType"),Ai=F(t=>t.codePointAt(0)===95,"isSpecialKey"),Ge=F((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),He=F(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Ke=F((t,e,n,a=!1)=>{t[e]===void 0?t[e]=a?[n]:n:a&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),Ci=F((t,e,n,a,r)=>{let i=e.get(t)??n.get(t);if(!i&&a){const u=t.toLowerCase();i=a.get(u)??r?.get(u)}return i},"getDefinition"),Ni=F((t,e,n,a)=>{const r=n.debug??!1;x(r,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(r,"Starting argument resolution","resolver"),x(r,"Tokens:","resolver",t),x(r,"Definitions:","resolver",e),x(r,"Processing tokens...","resolver");const i=new Map,u=new Map,s=n.caseInsensitive?new Map:void 0,m=n.caseInsensitive?new Map:void 0,o=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const f of e)if(i.set(f.name,f),f.alias&&u.set(f.alias,f),n.caseInsensitive&&s&&(s.set(f.name.toLowerCase(),f),f.alias&&m&&m.set(f.alias.toLowerCase(),f)),n.camelCase&&o&&c){const h=f.name.replaceAll(Oi,(v,y)=>y.toUpperCase());o.set(f.name,h),c.set(h,f.name)}const d={},l={},g=[],p=new Set;let b=!1;const $=e.find(f=>f.defaultOption),w=e.some(f=>f.group),C=e.some(f=>f.type===Number);for(let f=0;f<t.length;f++){const h=t[f];if(h.kind==="option-terminator"){d._unknown=a.slice(h.index),b=!0;break}if(h.kind==="option"&&h.name){let v=Ci(h.name,i,u,s,m);if(!v&&h.value===void 0&&C&&Pi.test(h.name)){const N=e.find(M=>M.type===Number);N&&(v=N,h.value=h.name,h.name=N.name)}const y=v?v.name:h.name,P=v?.multiple,E=v?.lazyMultiple;if(l[y]!==void 0&&!P&&!E&&!n.partial)throw new ei(y);if(!v&&n.partial){const N=h.rawName??`--${h.name}${h.value!==void 0&&h.inlineValue?`=${h.value}`:""}`;g.push({index:h.index,value:N});continue}if(!v&&n.stopAtFirstUnknown){d._unknown=a.slice(h.index);break}if(!v&&!n.partial)throw new ze(h.name);if(h.value===void 0){const N=t[f+1],M=N?.kind==="option"&&!("name"in N)&&N.value!==void 0,I=N&&v&&!(v.type&&we(v.type))&&(N.kind==="positional"||M),Bt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(I&&(!v?.defaultOption||Bt))if(P){let V=f+1;const ve=[];for(;V<t.length&&(t[V].kind==="positional"||t[V].kind==="option"&&!("name"in t[V])&&t[V].value!==void 0);)ve.push(t[V].value),p.add(t[V].index),V++;l[y]=l[y]===void 0?ve:Ge(l[y],ve),f=V-1}else E?(Ke(l,y,N.value,!0),p.add(N.index),f++):(l[y]=N.value,p.add(N.index),f++);else v?.type&&we(v.type)?Ke(l,y,!0,P):l[y]=P?[]:null}else{let{value:N}=h;if(v?.type&&we(v.type))switch(N){case"":{if(n.partial)l._unknown??=[],l._unknown.push(`${h.rawName??`--${h.name}`}${h.value?`=${h.value}`:""}`),N=!0;else throw new ze(h.name);break}case"false":{N=!1;break}case"true":{N=!0;break}default:N=!0}const M=[N];if(P){let I=f+1;for(;I<t.length&&t[I].kind==="positional";)M.push(t[I].value),p.add(t[I].index),I++;f=I-1}l[y]===void 0?l[y]=P||E?M:N:P||E?l[y]=Ge(l[y],M):l[y]=N}}else if(h.kind==="positional"&&n.stopAtFirstUnknown&&!p.has(h.index)&&!$){x(r,`Found unconsumed positional token at index ${String(h.index)}, stopping processing`,"resolver"),d._unknown=a.slice(h.index);break}}for(const[f,h]of Object.entries(l)){const v=i.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(h)&&(l[f]=[h])}let k=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!b){for(const f of t)if(f.kind==="option"&&!i.has(f.name??"")&&!u.has(f.name??"")&&(!n.caseInsensitive||!s?.has(f.name?.toLowerCase()??"")&&!m?.has(f.name?.toLowerCase()??""))){k=f.index;break}}if($){const f=[],h=[];for(const v of t)v.kind==="positional"&&!p.has(v.index)&&v.index<k&&(f.push(v.value),h.push(v));if(f.length>0){const v=l[$.name],y=$.multiple??$.lazyMultiple;v===void 0?y?(h.forEach(P=>p.add(P.index)),l[$.name]=f):(p.add(h[0].index),l[$.name]=f[0]):y&&(h.forEach(P=>p.add(P.index)),l[$.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!p.has(f.index))throw new ci(a[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...g];if(l._unknown){const h=new Map;for(const[v,y]of a.entries())h.set(y,v);for(const v of l._unknown){const y=h.get(v);y!==void 0&&f.push({index:y,value:v})}}for(const h of t)h.kind==="positional"&&!p.has(h.index)&&f.push({index:h.index,value:a[h.index]});f.length>0&&(f.sort((h,v)=>h.index-v.index),d._unknown=f.map(h=>h.value))}if(n.stopAtFirstUnknown&&!b){const f=t.findIndex(y=>y.kind==="option"&&!i.has(y.name??"")&&!u.has(y.name??"")&&(!n.caseInsensitive||!s?.has(y.name?.toLowerCase()??"")&&!m?.has(y.name?.toLowerCase()??""))),h=t.findIndex(y=>y.kind==="positional"&&!p.has(y.index));let v=-1;if(f!==-1&&h!==-1?v=Math.min(f,h):f!==-1?v=f:h!==-1&&(v=h),v>=0){const y=t[v].index;d._unknown=a.slice(y)}}else g.length>0&&!n.partial&&(d._unknown=g.map(f=>f.value));for(const[f,h]of Object.entries(l)){const v=n.camelCase?o?.get(f)??f:f,y=i.get(f);d[v]=y?.type?yi(h,y.type):h===void 0?null:h}for(const f of e){const h=n.camelCase?o?.get(f.name)??f.name:f.name;!(h in d)&&f.defaultValue!==void 0&&(f.multiple??f.lazyMultiple?d[h]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:d[h]=f.defaultValue)}if(w){const f={},h={},v={};for(const P of e)if(P.group){const E=Array.isArray(P.group)?P.group:[P.group];for(const N of E)He(N)||(f[N]??={})}for(const P of Object.keys(d))if(!Ai(P)){h[P]=d[P];let E=P;n.camelCase&&(E=c?.get(P)??P);const N=i.get(E);if(N?.group){const M=Array.isArray(N.group)?N.group:[N.group];for(const I of M)He(I)||f[I]&&(f[I][P]=d[P])}else v[P]=d[P]}const y={_all:h};for(const[P,E]of Object.entries(f))y[P]=E;Object.keys(v).length>0&&(y._none=v),d._unknown&&(y._unknown=d._unknown),Object.keys(d).forEach(P=>delete d[P]),Object.assign(d,y)}return x(r,"Final parsed result:","resolver",d),d},"resolveArgs");var ki=Object.defineProperty,q=J((t,e)=>ki(t,"name",{value:e,configurable:!0}),"l");const W="-".codePointAt(0),z="=",_i=z.codePointAt(0),Ei="--",xi="-",Li="--",At=q(t=>t.length>2&&t.startsWith(Li),"hasLongOptionPrefix"),ji=q(t=>At(t)&&!t.includes(z,3),"isLongOption"),Ii=q(t=>At(t)&&t.includes(z,3),"isLongOptionAndValue"),Ui=q(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==W,"hasOptionValue"),Mi=q(t=>{if(t.length!==2||t.codePointAt(0)!==W||t.codePointAt(1)===W)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},"isShortOption"),Vi=q(t=>!(t.length<=2||t.codePointAt(0)!==W||t.codePointAt(1)===W),"isShortOptionGroup"),Ti=q(t=>{const e=[],n=[...t];let a=-1,r=0;for(;n.length>0;){const i=n.shift();if(i===void 0)break;const u=n[0];if(r>0?r--:a++,i===Ei){e.push({index:a,kind:"option-terminator"});const s=n.map((m,o)=>({index:a+o+1,kind:"positional",value:m}));e.push(...s),a+=n.length;break}if(Mi(i)){const s=i.charAt(1);let m;r?(e.push({index:a,kind:"option",name:s,rawName:i,value:m}),r===1&&Ui(u)&&(m=n.shift(),e.push({index:a,kind:"option",value:m}))):e.push({index:a,kind:"option",name:s,rawName:i,value:m}),m!==void 0&&++a;continue}if(Vi(i)&&!i.includes(z)){const s=[];let m="",o=!1;for(let c=1;c<i.length;c++){const d=i.charAt(c);o?m+=d:d.codePointAt(0)===_i?o=!0:s.push(`${xi}${d}`)}if(o)if(s.length>0){const c=s.pop();s.push(`${c}=${m}`)}else s.push(m);n.unshift(...s),r=s.length;continue}if(ji(i)){const s=i.slice(2);e.push({index:a,kind:"option",name:s,rawName:i});continue}if(Ii(i)){const s=i.indexOf(z),m=i.slice(2,s),o=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:m,rawName:i,value:o});continue}if(i.length>2&&i.codePointAt(0)===W&&i.codePointAt(1)!==W&&i.includes(z)){const s=i.indexOf(z),m=i.charAt(1),o=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:m,rawName:i,value:o});continue}e.push({index:a,kind:"positional",value:i})}return e},"parseArgsTokens");var Si=Object.defineProperty,Ee=J((t,e)=>Si(t,"name",{value:e,configurable:!0}),"d");const Di=/\d/,Bi=Ee(t=>t!=null&&(t===Boolean||typeof t=="function"&&t.name.startsWith("Boolean")),"isBooleanType"),Ri=Ee(t=>typeof t=="function","isValidCustomTypeFunction"),zi=Ee((t,e,n)=>{const a=n?.debug??!1;x(a,"Validating definitions:","validation",t,"caseInsensitive:",e);const r=new Set,i=new Set,u=new Set,s=new Set;let m=0;for(const o of t){if(x(a,"Checking definition:","validation",o),!o.name)throw x(a,"Validation failed: name is required","validation"),new j("Invalid option definition: name is required");if(typeof o.name!="string")throw new j("Invalid option definition: name must be a string");if(o.name.trim()==="")throw new j("Invalid option definition: name cannot be empty");const c=e?o.name.toLowerCase():"";if(r.has(o.name)||e&&u.has(c))throw new j(`Invalid option definition: duplicate name '${o.name}'`);if(i.has(o.name)||e&&s.has(c))throw new j(`Invalid option definition: name '${o.name}' conflicts with an existing alias`);if(r.add(o.name),e&&u.add(c),o.alias!==void 0){if(typeof o.alias!="string")throw new j("Invalid option definition: alias must be a string");if(o.alias.length!==1)throw new j("Invalid option definition: alias must be a single character");if(Di.test(o.alias))throw new j("Invalid option definition: alias cannot be numeric");if(o.alias==="-")throw new j('Invalid option definition: alias cannot be "-"');const d=e?o.alias.toLowerCase():"";if(i.has(o.alias)||e&&s.has(d))throw new j(`Invalid option definition: duplicate alias '${o.alias}'`);if(r.has(o.alias)||e&&u.has(d))throw new j(`Invalid option definition: alias '${o.alias}' conflicts with an existing option name`);i.add(o.alias),e&&s.add(d)}if(o.defaultOption&&(m++,o.type!==void 0&&Bi(o.type)))throw new j("Invalid option definition: defaultOption cannot be Boolean type");if(o.type!==void 0&&!(o.type===Boolean||o.type===Number||o.type===String||typeof o.type=="function"&&Ri(o.type)))throw new j("Invalid option definition: invalid type")}if(m>1)throw x(a,"Validation failed: multiple defaultOptions not allowed","validation"),new j("Invalid option definition: multiple defaultOptions not allowed");x(a,"Validation completed successfully","validation")},"validateDefinitions");var Wi=Object.defineProperty,Fi=J((t,e)=>Wi(t,"name",{value:e,configurable:!0}),"O");const qi=Fi((t,e={})=>{const n=e.debug??!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const a={...e};a.stopAtFirstUnknown&&(a.partial=!0);const r=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",r),zi(r,a.caseInsensitive,n?a:void 0);let{argv:i}=a;if(!i&&(i=process.argv.slice(2),process.execArgv.length>0)){const o=new Set(process.execArgv);i=i.filter(c=>!o.has(c))}x(n,"Using argv:","index",i);let u=i;a.caseInsensitive&&(u=i.map(o=>{if(o.startsWith("--")){const c=o.indexOf("="),d=(c===-1?o.slice(2):o.slice(2,c)).toLowerCase();return c===-1?`--${d}`:`--${d}${o.slice(c)}`}if(o.startsWith("-")&&!o.startsWith("--")&&o.length>1){const c=o.slice(1).split("=",2),d=c[0],l=c[1];if(!d)return o;const g=d.toLowerCase();return l===void 0?`-${g}`:`-${g}=${l}`}return o}));const s=Ti(u.map(String));x(n,"Tokenized arguments:","index",s);const m=Ni(s,r,a,i);return x(n,"Command-line-args parsing completed","index"),m},"commandLineArgs");var Gi=Object.defineProperty,Hi=O((t,e)=>Gi(t,"name",{value:e,configurable:!0}),"b$2");let Ki=class{static{O(this,"m")}static{Hi(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}};var Yi=Object.defineProperty,Ji=O((t,e)=>Yi(t,"name",{value:e,configurable:!0}),"n$6");let be=class extends A{static{O(this,"i")}static{Ji(this,"CommandLoaderError")}commandName;constructor(e,n,a){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",a!==void 0&&(this.cause=a)}};var Qi=Object.defineProperty,Xi=O((t,e)=>Qi(t,"name",{value:e,configurable:!0}),"f$5");const Zi=/^-{1,2}(\w+)(=(.+))?$/,Ct=Xi((t,e,n,a)=>{const r=Zi.exec(t);if(r===null)return{};const i=r[1];if(!i)return{};const u=n&&a?n.get(i)??a.get(i):e.find(s=>s.name===i||s.alias===i);return u!==void 0?{argName:u.name,argValue:r[3],option:u}:{}},"getParameterOption");var ea=Object.defineProperty,_e=O((t,e)=>ea(t,"name",{value:e,configurable:!0}),"e$3");const Ye=_e((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),ta=new Set(["0","1","false","true"]),na=_e((t,e,n,a)=>{if(e.length===0||t.length===0)return{};const r=_e((i,u)=>{const{argName:s,argValue:m,option:o}=Ct(u,e,n,a),{lastOption:c}=i;return o&&ne(o)&&m&&s?i.partial[s]=Ye(m,o):i.lastName&&c&&ne(c)&&ta.has(u)&&(i.partial[i.lastName]=Ye(u,c)),{lastName:s,lastOption:o,partial:i.partial}},"getBooleanValue");return t.reduce(r,{partial:{}}).partial},"getBooleanValues");var ia=Object.defineProperty,Je=O((t,e)=>ia(t,"name",{value:e,configurable:!0}),"s$8");const aa=new Set(["0","1","false","true"]),oa=Je((t,e,n,a)=>{if(e.length===0||t.length===0)return t;const r=Je((i,u)=>{const{argValue:s,option:m}=Ct(u,e,n,a),{lastOption:o}=i;if(o&&ne(o)&&aa.has(u)){const{args:c}=i;return{args:c.slice(0,-1)}}return m&&ne(m)&&s?{args:i.args}:{args:[...i.args,u],lastOption:m}},"removeBooleanArguments");return t.reduce(r,{args:[]}).args},"removeBooleanValues");var ra=Object.defineProperty,sa=O((t,e)=>ra(t,"name",{value:e,configurable:!0}),"o$8");const Qe=sa(t=>{const e=new Map;for(const n of t){const a=e.get(n.name);a?e.set(n.name,{...a,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var la=Object.defineProperty,pe=O((t,e)=>la(t,"name",{value:e,configurable:!0}),"o$7");const ca=pe(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),ua=pe((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return ca(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},"transformEnvValue"),pa=/_./g,fa=/^[A-Z]/,da=pe(t=>t.toLowerCase().replaceAll(pa,e=>e[1]?.toUpperCase()??e).replace(fa,e=>e.toLowerCase()),"toCamelCase"),ha=pe(t=>{if(!t||t.length===0)return{};const e={},n=R();for(const a of t){const r=n[a.name],i=ua(a,r),u=i===void 0?a.defaultValue:i,s=da(a.name);e[s]=u}return e},"processEnvVariables");var ma=Object.defineProperty,ie=O((t,e)=>ma(t,"name",{value:e,configurable:!0}),"a$5");const ga=ie(t=>{const e=new Map,n=new Map;for(const a of t)if(e.set(a.name,a),a.alias){const r=Array.isArray(a.alias)?a.alias:[a.alias];for(const i of r)n.set(i,a)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),Nt=ie(async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new be(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(a){throw new be(t.name,a instanceof Error?a.message:String(a),a)}const n=e.default;if(typeof n!="function")throw new be(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},"loadLazyHandler"),va=ie((t,e,n,a)=>{const r=new Ki(t.name,t),{_all:i,_unknown:u,positionals:s}=e,m=Object.keys(n).length>0?{...i,...n}:i;re in m&&delete m[re],r.argument=s?.[re]??[],r.rawUnknown=[...u??[]];const o=Object.keys(a).length>0;return r.options=o?{...m,...a}:m,r.env=ha(t.env),r},"prepareToolbox"),ya=ie((t,e,n)=>{const a=t.options??[],r=a.length>0;let i=Qe(r?[...a,...n]:n);if(i.length>0){for(const o of i)if(o.multiple&&o.lazyMultiple)throw new Error(`Argument "${o.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:re,type:t.argument.type,typeLabel:t.argument.typeLabel},...i]);let u,s;if(r){const{optionMapByAlias:o,optionMapByName:c}=ga(a);u=oa(e,a,c,o),s=na(e,a,c,o)}else u=e,s={};const m=qi(i,{argv:u,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:s,parsedArgs:m}},"processCommandArgs"),H=ie(async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await Nt(t))(e),"executeCommand");var wa=Object.defineProperty,ba=O((t,e)=>wa(t,"name",{value:e,configurable:!0}),"n$5");let $a=class extends A{static{O(this,"s")}static{ba(this,"CommandValidationError")}commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}};var Oa=Object.defineProperty,Pa=O((t,e)=>Oa(t,"name",{value:e,configurable:!0}),"t$5");const Xe=Pa((t,e,n=!1)=>{const a=[];for(const r of t)if(!(!n&&!r.required)&&e[r.name]===void 0){if(r.type?.name==="Boolean"){e[r.name]=!1;continue}a.push(r)}return a},"listMissingArguments");var Aa=Object.defineProperty,kt=O((t,e)=>Aa(t,"name",{value:e,configurable:!0}),"n$4");const Ca=kt((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:an(t,e)<=t.length/3,"isSimilar"),B=kt((t,e)=>{const n=t.toLowerCase();return e.filter(a=>Ca(a.toLowerCase(),n))},"findAlternatives");var Na=Object.defineProperty,fe=O((t,e)=>Na(t,"name",{value:e,configurable:!0}),"a$4");const ka=fe((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(a=>{const r=a.startsWith("--");let i=`Found unknown ${r?"option":"argument"} "${a}"`;if(r){const u=B(a.replace("--",""),(e.options??[]).map(s=>s.name));if(u.length>0){const[s,...m]=u.map(o=>`--${o}`);i+=m.length>0?`, did you mean ${s??""} or ${m.join(", ")}?`:`, did you mean ${s??""}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
2
+ `))},"validateUnknownOptions"),_a=fe((t,e,n)=>{const a=n.__requiredOptions__,r=a?Xe(a,e,!0):Xe(t,e,!1);if(r.length>0)throw new $a(n.name,r.map(i=>i.name));e._unknown&&e._unknown.length>0&&!n.argument&&ka(e,n)},"validateRequiredOptions"),Ea=fe((t,e,n)=>{const a=n.__conflictingOptions__??t.filter(r=>r.conflicts!==void 0);if(a.length>0){const r=a.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(u=>e[u]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(r)throw new at(r.name,typeof r.conflicts=="string"?r.conflicts:r.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),xa=fe(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const r of t.options){if(r.name){const i=e.get(r.name)??[];i.push(r),e.set(r.name,i)}if(typeof r.alias=="string"&&r.alias.length>0){const i=n.get(r.alias)??[];i.push(r),n.set(r.alias,i)}else if(Array.isArray(r.alias)){for(const i of r.alias)if(i.length>0){const u=n.get(i)??[];u.push(r),n.set(i,u)}}}const a=[];for(const[r,i]of e)i.length>1&&a.push(`Duplicate option name "${r}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[r,i]of n)i.length>1&&a.push(`Duplicate option alias "-${r}" used by options ${i.map(u=>`"${u.name}"`).join(", ")} in command "${t.name}"`);if(a.length>0)throw new Error(a.join(`
3
+ `))},"validateDuplicateOptions");var La=Object.defineProperty,xe=O((t,e)=>La(t,"name",{value:e,configurable:!0}),"s$4");const ja=xe((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let a;for(let r=1;r<=e.length;r+=1){const i=e[r-1];if(i===void 0||i.startsWith("-"))break;n.push(i);const u=n.join(" ");t.has(u)&&(a={commandPath:[...n],depth:r})}return a?{argv:e.slice(a.depth),commandPath:a.commandPath}:{argv:e,commandPath:void 0}},"parseNestedCommand"),D=xe(t=>t.join(" "),"getCommandPathKey"),Ze=xe((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Ia=Object.defineProperty,_t=O((t,e)=>Ia(t,"name",{value:e,configurable:!0}),"i$5"),Ua=Object.defineProperty,Et=_t((t,e)=>Ua(t,"name",{value:e,configurable:!0}),"r"),Ma=Object.defineProperty,Va=Et((t,e)=>Ma(t,"name",{value:e,configurable:!0}),"c");let xt=class{static{O(this,"l")}static{_t(this,"y")}static{Et(this,"s")}static{Va(this,"LRUCache")}capacity;cache;keyOrder;constructor(e){this.capacity=e,this.cache=new Map,this.keyOrder=[]}get(e){if(this.cache.has(e))return this.keyOrder=this.keyOrder.filter(n=>n!==e),this.keyOrder.push(e),this.cache.get(e)}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.keyOrder=this.keyOrder.filter(a=>a!==e);else if(this.cache.size>=this.capacity){const a=this.keyOrder.shift();a!==void 0&&this.cache.delete(a)}this.cache.set(e,n),this.keyOrder.push(e)}delete(e){this.cache.delete(e),this.keyOrder=this.keyOrder.filter(n=>n!==e)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};var Ta=Object.defineProperty,Sa=O((t,e)=>Ta(t,"name",{value:e,configurable:!0}),"r$5"),Da=Object.defineProperty,Ba=Sa((t,e)=>Da(t,"name",{value:e,configurable:!0}),"a"),Ra=Object.defineProperty,za=Ba((t,e)=>Ra(t,"name",{value:e,configurable:!0}),"s");const Wa=za((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Fa=Object.defineProperty,qa=O((t,e)=>Fa(t,"name",{value:e,configurable:!0}),"I"),Ga=Object.defineProperty,de=qa((t,e)=>Ga(t,"name",{value:e,configurable:!0}),"W");const Ha=Cn(import.meta.url),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ka=de(t=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[e,n]=Z.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Z.getBuiltinModule(t)}return Ha(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Ya}=Ka("node:util");var Ja=Object.defineProperty,Qa=de((t,e)=>Ja(t,"name",{value:e,configurable:!0}),"g");const $e=new xt(1e3),Xa=/[.*+?^${}()|[\]\\]/g,Za=Qa(t=>{const e=t.join("");if($e.has(e))return $e.get(e);const n=t.map(r=>r.replaceAll(Xa,String.raw`\$&`)).join("|"),a=new RegExp(n,"g");return $e.set(e,a),a},"getSeparatorsRegex");var eo=Object.defineProperty,to=de((t,e)=>eo(t,"name",{value:e,configurable:!0}),"t");const no=to(t=>{const e=[];let n=0,a;for(te.lastIndex=0;(a=te.exec(t))!==null;)a.index>n&&e.push(t.slice(n,a.index)),e.push(a[0]),n=te.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var io=Object.defineProperty,_=de((t,e)=>io(t,"name",{value:e,configurable:!0}),"u");const ao=/[ČŠŽĐ]/i,Lt=new Uint8Array(128),jt=new Uint8Array(128),It=new Uint8Array(128);for(let t=0;t<128;t++)Lt[t]=t>=65&&t<=90?1:0,jt[t]=t>=97&&t<=122?1:0,It[t]=t>=48&&t<=57?1:0;const Oe=_(t=>Lt[t],"isUpper"),et=_(t=>jt[t],"isLower"),Pe=_(t=>It[t],"isDigit"),T=_((t,e,n,a,r)=>{if(t.length===0)return[];let i=!1;const u=Object.values(e);for(const g of u)if(g(t[0])){i=!0;break}if(!i&&!n)return[t];const s=[...t],m=[];let o=s[0],c="other";const d=Object.entries(e);for(const g of d){const[p,b]=g;if(b(s[0])){c=p;break}}let l=n&&a?s[0]===s[0].toLocaleUpperCase(a):!1;for(let g=1;g<s.length;g++){const p=s[g];let b="other";for(const C of d){const[k,f]=C;if(f(p)){b=k;break}}const $=n&&a?p===p.toLocaleUpperCase(a):!1;let w=!1;r?w=r(c,b,l,$,p,g,s):(c!==b&&c!=="other"&&b!=="other"&&(w=!0),n&&b!=="other"&&!l&&$&&(w=!0)),w?(m.push(o),o=p):o+=p,c=b,n&&(l=$)}return o&&o.length>0&&m.push(o),m.length>0?m:[t]},"handleScriptTransitions"),oo=_((t,e,n,a)=>{if(n.size===0)return e;for(const r of n)if(t.startsWith(r,e))return a.push(r),e+r.length;return e},"detectAndProcessAcronym"),Ut=_((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const a=[],r=t.length;for(let i=1;i<r;i++){const u=oo(t,n,e,a);if(u!==n){n=u,i=n-1;continue}const s=t.codePointAt(i-1),m=t.codePointAt(i),o=s&&s<128&&Oe(s),c=m&&m<128&&Oe(m),d=s&&s<128&&et(s),l=s&&s<128&&Pe(s),g=m&&m<128&&Pe(m);if(d&&c){a.push(t.slice(n,i)),n=i;continue}if(l&&!g||!l&&g){a.push(t.slice(n,i)),n=i;continue}if(g&&!l){let p=!1,b=!1;if(i+1<r){const $=t.codePointAt(i+1);p=$&&$<128&&Oe($),b=$&&$<128&&Pe($)}if(!b&&p){a.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<r){const p=t.codePointAt(i+1),b=p&&p<128&&et(p);if(o&&c&&b){const $=t.slice(n,i+1);e.has($)||(a.push(t.slice(n,i)),n=i)}}}return n<r&&a.push(t.slice(n)),a.filter(i=>i!=="")},"splitCamelCaseFast"),Mt=_((t,e,n)=>{if(t.length===0)return[];const a=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!a&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const o=[...t],c=o.length,d=[];let l=o[0],g=o[0]===o[0].toLocaleUpperCase(e),p=g,b=g?0:-1;for(let $=1;$<c;$++){const w=o[$],C=w===w.toLocaleUpperCase(e);if(C===g)l+=w;else if(C)l&&l.length>0&&(d.push(l),l=w),p=!0,b=$;else{if(p&&$-b>1){const k=o[$-1],f=l.slice(0,-1);f&&f.length>0&&d.push(f),l=k+w}else l+=w;p=!1,b=-1}g=C}return l&&l.length>0&&d.push(l),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!G.test(t)&&!L.test(t))return[t];const o=[...t],c=o.length,d=[];let l=o[0];const g=o[0];let p;G.test(g)?p=1:L.test(g)?p=2:p=0;let b=g===g.toLocaleUpperCase(e);for(let w=1;w<c;w++){const C=o[w];let k;G.test(C)?k=1:L.test(C)?k=2:k=0;const f=C===C.toLocaleUpperCase(e);p!==k&&(p===1||p===2)&&(k===1||k===2)||k===p&&!b&&f?(d.push(l),l=C):l+=C,p=k,b=f}l&&l.length>0&&d.push(l);const $=[];for(let w=0;w<d.length;w++)w<d.length-1&&d[w].length===1&&L.test(d[w])&&G.test(d[w+1][0])?($.push(d[w]+d[w+1]),w+=1):$.push(d[w]);return $}if(e.startsWith("el")){if(!ye.test(t)&&!L.test(t))return[t];const o=[];Ue.lastIndex=0;let c;for(;(c=Ue.exec(t))!==null;)o.push(c[0]);o.length===0&&o.push(t);const d=[];if(o.length===1){const l=o[0];if(!l||!ye.test(l[0])||l.length===1)return[l??t]}for(const l of o){if(!l)continue;if(!ye.test(l[0])||l.length===1){d.push(l);continue}const g=l.length;let p=l[0],b=l[0]===l[0].toLocaleUpperCase(e);for(let $=1;$<g;$++){const w=l[$],C=w===w.toLocaleUpperCase(e);!b&&C?(d.push(p),p=w):p+=w,b=C}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const o=e.startsWith("ja"),c=o?{hiragana:_(l=>ln.test(l),"hiragana"),kanji:_(l=>Me.test(l),"kanji"),katakana:_(l=>sn.test(l),"katakana"),latin:_(l=>L.test(l),"latin")}:{hangul:_(l=>Ve.test(l),"hangul"),latin:_(l=>L.test(l),"latin")},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(o){const l=T(t,c,!1,e,(p,b)=>p==="hiragana"&&b==="katakana"||p==="katakana"&&b==="hiragana"||p==="hiragana"&&b==="latin"||p==="katakana"&&b==="latin"||p==="kanji"&&b==="latin"||p==="latin"&&(b==="hiragana"||b==="katakana"||b==="kanji")),g=[];for(const p of l){const b=p;b.length===1&&d.has(b)&&g.length>0?g[g.length-1]=g.at(-1)+b:g.push(b)}return g.length>0?g:[t]}return T(t,c,!1,e,(l,g)=>l==="hangul"&&g==="latin"||l==="latin"&&g==="hangul")}if(e.startsWith("sl")){const o=[...t],c=o.length,d=[];let l=o[0],g=o[0]===o[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const b=o[p],$=b===b.toLocaleUpperCase(e),w=ao.test(b),C=p<c-1&&o[p+1]===o[p+1].toLocaleUpperCase(e);!g&&$||w&&C?(d.push(l),l=b,w&&C&&(d.push(l),l="")):l+=b,g=$}return l&&l.length>0&&d.push(l),d}if(e.startsWith("zh"))return T(t,{han:_(o=>Me.test(o),"han"),latin:_(o=>L.test(o),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const o=_(c=>Te.test(c)||Se.test(c),"isRtlChar");return T(t,{latin:_(c=>L.test(c),"latin"),rtl:_(c=>o(c),"rtl")},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const o=_(c=>cn.test(c)||un.test(c)||pn.test(c)||fn.test(c)||dn.test(c)||hn.test(c)||mn.test(c)||gn.test(c)||vn.test(c)||yn.test(c)||wn.test(c)||bn.test(c)||$n.test(c)||On.test(c)||Pn.test(c)||An.test(c),"isIndicChar");return T(t,{indic:_(c=>o(c),"indic"),latin:_(c=>L.test(c),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return T(t,{cyrillic:_(o=>G.test(o),"cyrillic"),latin:_(o=>L.test(o),"latin")},!0,e);if(["ar","fa","he"].includes(e))return T(t,{latin:_(o=>L.test(o),"latin"),rtl:_(o=>Te.test(o)||Se.test(o),"rtl")},!1,e);if(e.startsWith("ko"))return T(t,{hangul:_(o=>Ve.test(o),"hangul"),latin:_(o=>L.test(o),"latin")},!1,e);if(e.startsWith("uz")){if(!G.test(t)&&!L.test(t))return[t];const o=[...t],c=o.length,d=[];let l=o[0],g=o[0]===o[0].toLocaleUpperCase(e);for(let p=1;p<c;p++){const b=o[p],$=b===b.toLocaleUpperCase(e);if(De.test(b)||De.test(o[p-1])){l+=b;continue}!g&&$?(d.push(l),l=b):l+=b,g=$}return l&&l.length>0&&d.push(l),d}const r=[...t],i=r.length,u=[];let s=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(const o of n)if(t.startsWith(o)){u.push(o),s=r[o.length],m=s===s.toLocaleUpperCase(e);break}for(let o=1;o<i;o++){const c=r[o],d=c===c.toLocaleUpperCase(e);let l=0;for(const g of n)if(t.startsWith(g,o)){u.push(s,g),l=g.length,s="";const p=g.at(-1);p&&(m=p===p.toLocaleUpperCase(e));break}if(l>0){o+=l-1;continue}!m&&d?(u.push(s),s=c):s+=c,m=d}return s&&u.push(s),u},"splitCamelCaseLocale"),ro=_((t,e,n)=>{const a=[],r=ee.test(t)?t.split(ee).filter(Boolean):[t];for(const i of r){const u=i;if(ee.test(u))a.push(u);else{const s=te.test(u)?no(u).filter(Boolean):[u];for(const m of s)if(te.test(m))a.push(m);else if(e){const o=e.toLowerCase().split("-")[0];a.push(...Mt(m,o,n))}else a.push(...Ut(m,n))}}return a},"processTextWithAnsiEmoji"),so=_((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:a=!1,knownAcronyms:r=[],locale:i,normalize:u=!1,separators:s,stripAnsi:m=!1,stripEmoji:o=!1}=e,c=new Set([...r].toSorted((w,C)=>C.length-w.length));let d=t;m&&(d=Ya(d)),o&&(d=on(d));let l;Array.isArray(s)?l=Za(s):s instanceof RegExp?l=s:l=rn;const g=[];let p=d;const b=l.flags.includes("g")?l:new RegExp(l.source,`${l.flags}g`);for(;p.length>0;){const w=b.exec(p);if(!w){p===".."?g.push(".."):p==="."?g.push("."):p.length>0&&g.push(p);break}const C=w.index,k=w[0],f=k.length,h=p.slice(0,C),v=p.slice(C+f);if(k.startsWith("../"))g.push(".."),p=p.slice(C+3);else if(k.startsWith("./"))g.push("."),p=p.slice(C+2);else if(C===0&&k==="..")g.push(".."),p=p.slice(2);else if(C===0&&k===".")g.push("."),p=p.slice(1);else{h.length>0&&g.push(h);let y=0;for(;(y=k.indexOf("../",y))!==-1;)g.push(".."),y+=3;for(y=0;(y=k.indexOf("./",y))!==-1;)(y===0||k[y-1]!==".")&&g.push("."),y+=2;let P=v;for(;P.startsWith("../");)g.push(".."),P=P.slice(3);for(;P.startsWith("./");)g.push("."),P=P.slice(2);if(P===".."){g.push("..");break}else if(P==="."){g.push(".");break}else p=P}b.lastIndex=0}if(g.length===0){const w=d.split(l).filter(Boolean);g.push(...w)}let $=[];for(const w of g)n||a?$.push(...ro(w,i,c)):i?$.push(...Mt(w,i,c)):$.push(...Ut(w,c));return u&&($=$.map(w=>c.has(w)?w:i&&w===w.toLocaleUpperCase(i)?w[0]+w.slice(1).toLocaleLowerCase(i):w.toUpperCase()===w&&!c.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),$},"splitByCase");var lo=Object.defineProperty,co=O((t,e)=>lo(t,"name",{value:e,configurable:!0}),"r$4"),uo=Object.defineProperty,po=co((t,e)=>uo(t,"name",{value:e,configurable:!0}),"o"),fo=Object.defineProperty,ho=po((t,e)=>fo(t,"name",{value:e,configurable:!0}),"s");const mo=ho((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var go=Object.defineProperty,vo=O((t,e)=>go(t,"name",{value:e,configurable:!0}),"r$3"),yo=Object.defineProperty,wo=vo((t,e)=>yo(t,"name",{value:e,configurable:!0}),"r"),bo=Object.defineProperty,$o=wo((t,e)=>bo(t,"name",{value:e,configurable:!0}),"n");const Oo=$o((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var Po=Object.defineProperty,Ao=O((t,e)=>Po(t,"name",{value:e,configurable:!0}),"i$3"),Co=Object.defineProperty,No=Ao((t,e)=>Co(t,"name",{value:e,configurable:!0}),"f"),ko=Object.defineProperty,_o=No((t,e)=>ko(t,"name",{value:e,configurable:!0}),"l");const Eo=_o((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const a=[];let r="",i="";for(let u=0;u<n;u++){const s=t[u];if(ee.test(s)){r?(a.push(r+i+s),r="",i=""):(a.length>0&&a.push(e),r=s);continue}r?(i&&(i+=e),i+=s):(a.length>0&&a.push(e),a.push(s))}return a.join("")},"joinSegments");var xo=Object.defineProperty,Lo=O((t,e)=>xo(t,"name",{value:e,configurable:!0}),"r$2"),jo=Object.defineProperty,Io=Lo((t,e)=>jo(t,"name",{value:e,configurable:!0}),"a"),Uo=Object.defineProperty,Mo=Io((t,e)=>Uo(t,"name",{value:e,configurable:!0}),"e");const Vo=/(?<![a-zß])SS(?![a-z])/g,To=Mo(t=>t.replaceAll(Vo,"ß"),"normalizeGermanEszett");var So=Object.defineProperty,Do=O((t,e)=>So(t,"name",{value:e,configurable:!0}),"c$2"),Bo=Object.defineProperty,Ro=Do((t,e)=>Bo(t,"name",{value:e,configurable:!0}),"c"),zo=Object.defineProperty,Wo=Ro((t,e)=>zo(t,"name",{value:e,configurable:!0}),"o");const Fo=new xt(1e3),Vt=Wo((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,a=e?.cacheStore??Fo;let r;if(n&&(r=Oo(t,e)),n&&r&&a.has(r))return a.get(r);let i=!0;const u=Eo(so(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(s=>{if(e?.handleAnsi&&ee.test(s))return s;const m=e?.locale?.startsWith("de")?To(s):s,o=e?.locale?m.toLocaleLowerCase(e.locale):m.toLowerCase();return i?(i=!1,Wa(o,e)):mo(o,e)}),"");return n&&r&&a.set(r,u),u},"camelCase");var qo=Object.defineProperty,he=O((t,e)=>qo(t,"name",{value:e,configurable:!0}),"a$2");const Go=he(t=>{t.options?.forEach(e=>{e.__camelCaseName__=Vt(e.name)})},"processOptionNames"),Ho=he(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const a of t.options)e.add(a.name);const n=[];for(const a of t.options)if(a.name.startsWith("no-")){const r=a.name.replace("no-","");if(!e.has(r)){if(a.type!==Boolean)throw new Error(`Cannot add negated option "${a.name}" to command "${t.name}" because it is not a boolean.`);const i={...a,defaultValue:a.defaultValue===void 0?!0:!a.defaultValue,name:r};n.push(i),e.add(r)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),Ko=he((t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,a=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const u=Vt(i.name);a.set(u,i)}const r=Object.keys(n).filter(i=>a.has(i));if(r.length!==0)for(const i of r){const u=i.charAt(2);if(!u)continue;const s=u.toLowerCase()+i.slice(3),m=a.get(i);m&&(m.__negated__=!0),n[s]=!n[i],Reflect.deleteProperty(n,i)}},"mapNegatableOptions"),Yo=he((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const r of e.options)r.__camelCaseName__&&r.__negated__===void 0&&r.implies!==void 0&&n.set(r.__camelCaseName__,r);if(n.size===0)return;const{options:a}=t;for(const r of Object.keys(a)){const i=n.get(r);if(i?.implies){const{implies:u}=i;for(const[s,m]of Object.entries(u))a[s]===void 0&&(a[s]=m)}}},"mapImpliedOptions");var Jo=Object.defineProperty,me=O((t,e)=>Jo(t,"name",{value:e,configurable:!0}),"e$2");const Qo=me(()=>!!process.versions.electron,"isElectronApp"),Xo=me(()=>Qo()&&!process.defaultApp,"isBundledElectronApp"),Zo=me(()=>Xo()?0:1,"getProcessArgvBinIndex"),er=me(t=>t.slice(Zo()+1),"hideBin");var tr=Object.defineProperty,Tt=O((t,e)=>tr(t,"name",{value:e,configurable:!0}),"e$1");const nr=" ",ir=Tt((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,a)=>n===e[a]),"equals"),ar=Tt(t=>{if(typeof t=="string")return t.split(nr);const e=ke();return ir(t,e)?er(t):t},"parseRawCommand");var or=Object.defineProperty,Ae=O((t,e)=>or(t,"name",{value:e,configurable:!0}),"r");const rr=Ae(t=>{const e=Ae(i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),Y(1)},"uncaughtExceptionHandler"),n=Ae((i,u)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let s;if(typeof i=="string")s=i;else try{s=JSON.stringify(i)}catch{s=String(i)}t.error(`Promise rejection: ${s}`)}Y(1)},"unhandledRejectionHandler"),a=Ie("uncaughtException",e),r=Ie("unhandledRejection",n);return()=>{a(),r()}},"registerExceptionHandler");var sr=Object.defineProperty,Q=O((t,e)=>sr(t,"name",{value:e,configurable:!0}),"e");const se=100,St=/^[a-z][\w-]*$/i,le=Q((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new A(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"validateNonEmptyString"),tt=Q((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new A(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateStringArray");Q((t,e)=>{if(typeof t!="function")throw new A(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const Ce=Q((t,e)=>{if(typeof t!="object"||t===null)throw new A(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),oe=Q(t=>{const e=le(t,"Command name");if(e.length>se)throw new A(`Command name is too long (maximum ${String(se)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new A(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!St.test(e))throw new A(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"validateCommandName");Q(t=>{const e=le(t,"Plugin name");if(e.length>se)throw new A(`Plugin name is too long (maximum ${String(se)} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new A(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!St.test(e))throw new A(`Plugin name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_PLUGIN_NAME",{pluginName:e});return e},"validatePluginName");var lr=Object.defineProperty,ge=O((t,e)=>lr(t,"name",{value:e,configurable:!0}),"s");const cr=new Set([`
4
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),ur=/^[A-Z]:/i,pr=ge(t=>{if(typeof t!="string")throw new TypeError("Argument must be a string");if(t.length>1e4)throw new Error(`Argument is too long (maximum ${String(1e4)} characters)`);for(const e of t)if(cr.has(e))throw new Error(`Argument contains dangerous character: ${e}`);return t.trim()},"sanitizeArgument"),nt=ge(t=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error(`Too many arguments (maximum ${String(100)})`);return t.map(e=>pr(e))},"sanitizeArguments");ge(t=>{if(typeof t!="string")throw new TypeError("Path must be a string");const e=t.trim();if(e.includes("..")||e.includes("../")||e.includes("..\\"))throw new Error("Path contains directory traversal sequences");if(e.startsWith("/")||ur.test(e))throw new Error("Absolute paths are not allowed");if(e.length>1e3)throw new Error("Path is too long");return e},"validateSafePath");class Ir{static{O(this,"RateLimiter")}static{ge(this,"RateLimiter")}attempts=new Map;maxAttempts;windowMs;constructor(e=5,n=6e4){if(e<=0||n<=0)throw new Error("maxAttempts and windowMs must be positive numbers");this.maxAttempts=e,this.windowMs=n}checkLimit(e){const n=Date.now(),a=this.attempts.get(e);return!a||n>a.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):a.count>=this.maxAttempts?!1:(a.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,a]of this.attempts.entries())e>a.resetTime&&this.attempts.delete(n)}}var fr=Object.defineProperty,U=O((t,e)=>fr(t,"name",{value:e,configurable:!0}),"b");const dr=/^-([^\d-])$/,hr=/^--(\S+)/,mr=/^-([^\d-]{2,})$/,Ne=U(t=>dr.test(t)||hr.test(t)||mr.test(t),"isOption"),gr={access:U((t,e)=>Yt(t,e),"access"),mkdir:U((t,e)=>Kt(t,e),"mkdir"),readdir:U(t=>Ht(t),"readdir"),readFile:U((async(t,e)=>e===void 0?Le(t):Le(t,e)),"readFile"),rm:U((t,e)=>Gt(t,e),"rm"),stat:U(t=>qt(t),"stat"),writeFile:U((t,e,n)=>Ft(t,e,n),"writeFile")};class Dt{static{O(this,"Cli")}static{U(this,"Cli")}#t;#e;#c;#u;#f;#d;#w;#b;#$;#O;#P;#p;#n;#i;#a;#o;#r;#h=!1;#A;#C=!1;#m;#g;#v;#l=[];#x(){return this.#m===void 0&&(this.#m=[...this.#i.keys()]),this.#m}#N(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#s(){return this.#v===void 0&&(this.#v=[...this.#x(),...this.#N()]),this.#v}#k(){return this.#l.length===0?ae:[...ae,...this.#l]}#_(){this.#m=void 0,this.#g=void 0,this.#v=void 0}#y(){if(this.#c===void 0){const e=ar(this.#e.argv);this.#c=nt(e),this.#L()}return this.#c}#L(){if(!this.#c)return;const e=R();let n=!1;for(const a of this.#c){if(a==="--quiet"||a==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Jt),n=!0;break}if(a==="--verbose"||a==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Qt),n=!0;break}if(a==="--debug"||a==="-vvv"){e.CEREBRO_OUTPUT_LEVEL=String(K),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(K):String(je))}#j(){this.#C||(this.#A=rr(this.#t),this.#C=!0)}#I(){return{arch:Zt(),argv:this.#y(),cwd:this.#u,env:this.#O??R(),exit:this.#$??(e=>Y(e??0)),platform:Xt(),stdin:this.#P}}#E(e,n,a,r){this.#t.debug(`command '${r}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:u,parsedArgs:s}=ya(e,n,this.#k()),m=Object.keys(u).length>0;let o=s;m&&(o={...s,_all:{...s._all,...u}}),_a(i,o,e);const c=va(e,s,u,a);c.runtime=this,c.argv=this.#y(),c.fs=this.#b??gr,c.process=this.#I(),c.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const l=e.options.filter(g=>g.name.startsWith("no-"));for(const g of l){const p=g.name.replace("no-",""),b=`--${g.name}`,$=`--${p}`,w=n.includes(b),C=n.includes($);if(w&&C)throw new at(p,g.name)}}return d&&(Ko(c,e),Yo(c,e)),Ea(i,c.options,e),R().CEREBRO_OUTPUT_LEVEL===String(K)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:i,booleanValues:u,commandArgs:o,parsedArgs:s,toolbox:c}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new A("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const a=n.argv??ke(),r=n.cwd??en();if(this.#e={...n,argv:a,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new A("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new A("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new A("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new A("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const i=R();if(i.CEREBRO_OUTPUT_LEVEL=String(je),typeof this.#e.logger=="object"){const c=["debug","error","info","log","warn"],d=[],l=this.#e.logger;for(const g of c)typeof l[g]!="function"&&d.push(g);if(d.length>0)throw new A(`Logger object is missing required methods: ${d.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:d});this.#t=this.#e.logger}else this.#t={...console,debug:U((...c)=>{i.CEREBRO_OUTPUT_LEVEL===String(K)&&console.debug(...c)},"debug")};this.#d=this.#e.packageVersion,this.#w=this.#e.packageName,this.#u=this.#e.cwd,this.#o="help",this.#r={};const u=n.fs;if(u!==void 0&&(typeof u!="object"||u===null))throw new A("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const s=n.exit;if(s!==void 0&&typeof s!="function")throw new A("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const m=n.env;if(m!==void 0&&(typeof m!="object"||m===null))throw new A("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const o=n.stdin;if(o!==void 0&&typeof o!="string")throw new A("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#b=n.fs,this.#$=n.exit,this.#O=n.env,this.#P=n.stdin??"",this.#n=new Map,this.#i=new Map,this.#a=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#d?` v${this.#d}`:""}`),this.#r}setDefaultCommand(e){return this.#o=e,this}get defaultCommand(){return this.#o}addCommand(e){Ce(e,"Command"),oe(e.name);const n=typeof e.execute=="function",a=typeof e.loader=="function";if(n&&a)throw new A(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!a)throw new A(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?oe(e.alias):tt(e.alias,"Command alias").forEach(o=>oe(o))),e.argument&&Ce(e.argument,"Command argument"),e.options&&Ce(e.options,"Command options"),e.commandPath&&(tt(e.commandPath,"Command commandPath"),e.commandPath.forEach(o=>{oe(o)}));const r=Ze(e.name,e.commandPath),i=D(r);if(this.#i.has(i))throw new A(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const u=Array.isArray(e.commandPath)&&e.commandPath.length>0,s=this.#n.get(e.name),m=s!==void 0&&(s.commandPath===void 0||s.commandPath.length===0);if(!u&&m)throw new A(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const o of e.options)Re(o);if(xa(e),Ho(e),Go(e),e.options&&(e.__conflictingOptions__=e.options.filter(o=>o.conflicts!==void 0),e.__requiredOptions__=e.options.filter(o=>o.required===!0)),u&&s!==void 0)this.#n.set(i,e);else{if(!u&&s!==void 0&&!m){const o=Ze(s.name,s.commandPath);this.#n.set(D(o),s)}this.#n.set(e.name,e)}if(this.#i.set(i,r),this.#a.set(i,e),this.#_(),e.alias!==void 0){const o=typeof e.alias=="string"?[e.alias]:e.alias;for(const c of o){if(R().CEREBRO_OUTPUT_LEVEL===String(K)&&this.#t.debug("adding alias",c),this.#n.has(c))throw new A(`Command alias "${c}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:c,commandName:e.name});this.#n.set(c,e)}}return this}addGlobalOption(e){const n=e,a=new Set(ae.map(i=>i.name)),r=new Set(ae.map(i=>i.alias).filter(Boolean));if(a.has(n.name))throw new A(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&r.has(n.alias))throw new A(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(i=>i.name)).has(n.name))throw new A(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Re(n),this.#l.push(n),this}getGlobalOptions(){return this.#k()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new Un(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:U(e=>{e.logger=this.#t,e.console=e.logger},"execute"),name:"logger"}),this.#p)}getCliName(){return this.#f}getPackageVersion(){return this.#d}getPackageName(){return this.#w}getCommands(){return this.#n}getCwd(){return this.#u}dispose(){this.#A?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:a=!0,...r}=e;if(!this.#n.has("help")){const{default:h}=await import("../commands/help-command.js");this.addCommand(new h(this.#n))}const i=this.#N(),u=this.#i;this.#j();const s=this.#y();let m,o=[...s];const c=tn(),d=nn(),l=ke();this.#t.debug(`process.execPath: ${c}`),this.#t.debug(`process.execArgv: ${d.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const g=ja(u,[...s]);if(g.commandPath)m=g.commandPath,o=g.argv;else{if(s.length>1&&s[0]&&s[1]&&!Ne(s[0])&&!Ne(s[1])){const v=[];let y=0;for(;y<s.length;){const E=s[y];if(!E||Ne(E))break;v.push(E),y+=1}const P=D(v);if(v[0]&&!i.includes(v[0])){const E=this.#s(),N=B(P,E);throw new S(P,N)}}let h;try{h=Fn([null,...i],[...s])}catch(v){if(v instanceof Error&&v.name==="INVALID_COMMAND"&&"command"in v){const y=v.command,P=this.#s(),E=B(y,P);throw new S(y,E)}throw v}h.command&&(m=[h.command],o=h.argv)}if(!m)if(this.#o)m=[this.#o];else{const h=this.#s();throw new S("",h)}const p=D(m),b=this.#i.get(p);let $;if(b){if($=this.#a.get(p),!$||D(b)!==p){const h=this.#s(),v=B(p,h);throw new S(p,v)}}else{const h=m.at(-1);if($=h?this.#n.get(h):void 0,!$){const v=this.#s(),y=B(p,v);throw new S(p,y)}}if(typeof $.execute!="function"&&typeof $.loader!="function")return this.#t.error(`Command "${$.name}" has no function to execute.`),a?Y(1):void 0;const w=o;let C,k;try{({commandArgs:C,toolbox:k}=this.#E($,w,r,p))}catch(h){if(this.#t.error(h),a)return Y(1);throw h}const f=this.getPluginManager();try{!this.#h&&f.hasPlugins()&&(await f.init({cli:this,cwd:this.#u,logger:this.#t}),this.#h=!0),await f.executeLifecycle("execute",k),await f.executeLifecycle("beforeCommand",k);let h;const v=C.global;if(v?.help){const y=this.#n.get("help");if(!y)throw new A("Help command not found","COMMAND_NOT_FOUND");h=await H(y,k,C)}else if(v?.version??v?.V){const y=this.#n.get("version");if(!y)throw new A("Version command not found","COMMAND_NOT_FOUND");h=await H(y,k,C)}else h=await H($,k,C);return await f.executeLifecycle("afterCommand",k,h),a?Y(0):void 0}catch(h){throw await f.executeErrorHandlers(h,k),h}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:a=[],...r}=n;le(e,"Command name");const i=e.split(" ").filter(Boolean),u=D(i),s=this.#i.get(u)?this.#a.get(u):this.#n.get(e);if(!s){const l=this.#s(),g=B(u||e,l);throw new S(e,g)}if(typeof s.execute!="function"&&typeof s.loader!="function")throw new A(`Command "${s.name}" has no function to execute`,"INVALID_COMMAND",{commandName:s.name});const m=[...nt(a)];this.#t.debug(`running command '${e}' programmatically with args: ${m.join(", ")}`);const{commandArgs:o,toolbox:c}=this.#E(s,m,r,u||e),d=this.getPluginManager();try{!this.#h&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#u,logger:this.#t}),this.#h=!0),await d.executeLifecycle("execute",c),await d.executeLifecycle("beforeCommand",c);let l;const g=o.global;if(g?.help){const p=this.#n.get("help");if(!p)throw new A("Help command not found","COMMAND_NOT_FOUND");l=await H(p,c,o)}else if(g?.version??g?.V){const p=this.#n.get("version");if(!p)throw new A("Version command not found","COMMAND_NOT_FOUND");l=await H(p,c,o)}else l=await H(s,c,o);return await d.executeLifecycle("afterCommand",c,l),l}catch(l){throw await d.executeErrorHandlers(l,c),l}}clone(e){const n={...this.#e,...e},a=new Dt(this.#f,n);for(const[r,i]of this.#n)a.#n.set(r,i);for(const[r,i]of this.#i)a.#i.set(r,[...i]);for(const[r,i]of this.#a)a.#a.set(r,i);for(const r of this.#l)a.#l.push(r);return a.#o=this.#o,a.#r={...this.#r},a.#_(),a}async getAction(e){le(e,"Command name");const n=e.split(" ").filter(Boolean),a=D(n),r=this.#i.get(a)?this.#a.get(a):this.#n.get(e);if(!r){const i=this.#s(),u=B(a||e,i);throw new S(e,u)}if(typeof r.execute=="function")return r.execute;if(typeof r.loader=="function")return Nt(r);throw new A(`Command "${r.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:r.name})}}export{Dt as Cli};
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var a=(e,p)=>n(e,"name",{value:p,configurable:!0});var t=Object.defineProperty,c=a((e,p)=>t(e,"name",{value:p,configurable:!0}),"p"),g=Object.defineProperty,r=c((e,p)=>g(e,"name",{value:p,configurable:!0}),"e"),E=Object.defineProperty,S=r((e,p)=>E(e,"name",{value:p,configurable:!0}),"E");const i=String.raw,u=i`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,w=S(()=>new RegExp(i`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${u}(?:\u200D${u})*`,"gu"),"default");var R=Object.defineProperty,x=r((e,p)=>R(e,"name",{value:p,configurable:!0}),"p");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const s=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,b=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,l=w(),f=/[-_./\s]+/g,m=/(\u001B\[[0-9;]*[a-z])/i,d=new RegExp("\\p{Script=Arabic}","u"),y=new RegExp("\\p{Script=Bengali}","u"),B=new RegExp("\\p{Script=Cyrillic}","u"),v=new RegExp("\\p{Script=Devanagari}","u"),j=new RegExp("\\p{Script=Ethiopic}","u"),F=new RegExp("\\p{Script=Greek}","u"),O=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),h=new RegExp("\\p{Script=Gujarati}","u"),k=new RegExp("\\p{Script=Gurmukhi}","u"),G=new RegExp("\\p{Script=Hangul}","u"),H=new RegExp("\\p{Script=Hebrew}","u"),L=new RegExp("\\p{Script=Hiragana}","u"),M=new RegExp("\\p{Script=Han}","u"),P=new RegExp("\\p{Script=Kannada}","u"),T=new RegExp("\\p{Script=Katakana}","u"),K=new RegExp("\\p{Script=Khmer}","u"),z=new RegExp("\\p{Script=Lao}","u"),A=new RegExp("\\p{Script=Latin}","u"),C=new RegExp("\\p{Script=Malayalam}","u"),D=new RegExp("\\p{Script=Myanmar}","u"),q=new RegExp("\\p{Script=Oriya}","u"),I=new RegExp("\\p{Script=Sinhala}","u"),Z=new RegExp("\\p{Script=Tamil}","u"),_=new RegExp("\\p{Script=Telugu}","u"),$=new RegExp("\\p{Script=Thai}","u"),J=new RegExp("\\p{Script=Tibetan}","u"),N=/[\u02BB\u02BC\u0027]/u,Q=x(e=>e.replace(l,""),"stripEmoji");export{j as A,F as C,O as D,l as E,b as H,k as I,H as J,y as K,f as L,m as M,A as N,B as P,L as Q,d as T,M as U,P as V,T as W,K as X,C as Y,z as Z,G as _,D as a,q as e,s as h,J as i,$ as n,I as p,h as q,_ as r,Q as s,N as t,Z as u,v as z};
@@ -0,0 +1,6 @@
1
+ var ne=Object.defineProperty;var u=(e,i)=>ne(e,"name",{value:i,configurable:!0});import{createRequire as ae}from"node:module";import{h as $,H as j,E as q}from"./constants-DmzZF6_u-BmMwILI_.js";import{createTable as x}from"@visulima/tabular";import{NO_BORDER as E}from"@visulima/tabular/style";import le from"terminal-size";import de from"@visulima/colorize/template";import{d as ue}from"./runtime-process-DKHFvYkv.js";import{bold as fe}from"@visulima/colorize";const oe=ae(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=u(e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[i,r]=v.versions.node.split(".").map(Number);if(i>22||i===22&&r>=3||i===20&&r>=16)return v.getBuiltinModule(e)}return oe(e)},"__cjs_getBuiltinModule"),ce=se("node:os");var he=Object.defineProperty,V=u((e,i)=>he(e,"name",{value:i,configurable:!0}),"u$1"),pe=Object.defineProperty,S=V((e,i)=>pe(e,"name",{value:i,configurable:!0}),"l");const me=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ge=12288,we=65510,be=[12288,12288,65281,65376,65504,65510],ye=8361,ve=65518,$e=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],We=32,Oe=10630,Ie=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ae=4352,je=262141,Q=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Ne=Object.defineProperty,xe=S((e,i)=>Ne(e,"name",{value:i,configurable:!0}),"r$1");const O=xe((e,i)=>{let r=0,a=Math.floor(e.length/2)-1;for(;r<=a;){const o=Math.floor((r+a)/2),s=o*2;if(i<e[s])a=o-1;else if(i>e[s+1])r=o+1;else return!0}return!1},"isInRange");var Ee=Object.defineProperty,g=S((e,i)=>Ee(e,"name",{value:i,configurable:!0}),"r");const G=19968,[Pe,Me]=T(Q);function T(e){let i=e[0],r=e[1];for(let a=0;a<e.length;a+=2){const o=e[a],s=e[a+1];if(G>=o&&G<=s)return[o,s];s-o>r-i&&(i=o,r=s)}return[i,r]}u(T,"c$2");V(T,"f");S(T,"k");g(T,"findWideFastPathRange");const X=g(e=>e<161||e>1114109?!1:O(me,e),"isAmbiguous"),Z=g(e=>e<ge||e>we?!1:O(be,e),"isFullWidth"),ke=g(e=>e<ye||e>ve?!1:O($e,e),"isHalfWidth"),Se=g(e=>e<We||e>Oe?!1:O(Ie,e),"isNarrow"),ee=g(e=>e>=Pe&&e<=Me?!0:e<Ae||e>je?!1:O(Q,e),"isWide");function R(e){return X(e)?"ambiguous":Z(e)?"fullwidth":ke(e)?"halfwidth":Se(e)?"narrow":ee(e)?"wide":"neutral"}u(R,"g$3");V(R,"S");S(R,"getCategory");g(R,"getCategory");var Te=Object.defineProperty,C=u((e,i)=>Te(e,"name",{value:i,configurable:!0}),"i$2"),Re=Object.defineProperty,_=C((e,i)=>Re(e,"name",{value:i,configurable:!0}),"a"),Ce=Object.defineProperty,Y=_((e,i)=>Ce(e,"name",{value:i,configurable:!0}),"e");function I(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}u(I,"s$1");C(I,"s");_(I,"r");Y(I,"validate");function A(e){return I(e),R(e)}u(A,"r$3");C(A,"p");_(A,"eastAsianWidthType");Y(A,"eastAsianWidthType");function D(e,{ambiguousAsWide:i=!1}={}){return I(e),Z(e)||ee(e)||i&&X(e)?2:1}u(D,"o$2");C(D,"W");_(D,"eastAsianWidth");Y(D,"eastAsianWidth");var _e=Object.defineProperty,Le=u((e,i)=>_e(e,"name",{value:i,configurable:!0}),"E"),Fe=Object.defineProperty,Be=Le((e,i)=>Fe(e,"name",{value:i,configurable:!0}),"A"),He=Object.defineProperty,L=Be((e,i)=>He(e,"name",{value:i,configurable:!0}),"d");const K=new Map,N=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,P=L(e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other","getCharType"),qe=L((e,i)=>{const r=Math.floor(e/65536),a=e%65536;let o=K.get(r);if(o||(o=new Map,K.set(r,o)),o.has(a))return o.get(a);let s;if(P(e)==="latin")s=i.width.regular;else if(P(e)==="control")s=i.width.control;else if(P(e)==="wide")s=i.width.wide;else switch(A(e)){case"ambiguous":{s=i.width.ambiguousIsNarrow?i.width.regular:i.width.wide;break}case"fullwidth":{s=i.width.fullWidth;break}case"wide":{s=i.width.wide;break}default:s=i.width.regular}return o.set(a,s),s},"getCachedCharWidth"),ze=L(e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,"isCombiningCharacter"),z=L((e,i={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:i.countAnsiEscapeCodes??!1,ellipsis:i.ellipsis??"",ellipsisWidth:i.ellipsisWidth??(i.ellipsis?z(i.ellipsis,{...i,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:i.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:i.ambiguousIsNarrow??!1,ansi:i.ansiWidth??0,control:i.controlWidth??0,emoji:i.emojiWidth??2,fullWidth:i.fullWidth??2,halfWidth:i.halfWidth??1,regular:i.regularWidth??1,tab:i.tabWidth??8,wide:i.wideWidth??2}},a=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,s=o>1e4;let t=0,n=0,l=o,d=!1;const w=e.includes("\x1B")||e.includes("›");for(;t<o;){if(w&&(e[t]==="\x1B"||e[t]==="›")){if(e.startsWith("\x1B]8;;",t)){const h="\x1B]8;;\x07",m=h.length,F=e.indexOf("\x07",t+5);if(F!==-1){const B=e.indexOf(h,F+1);if(B!==-1){const re=B+m,te=e.slice(F+1,B).replace($,""),U=z(te,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,a-n),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),H=U.width;if(U.truncated)d=!0,l=Math.min(l,t);else if(n+H>a&&(l=Math.min(l,t),d=!0,n+H>r.truncation.limit))break;if(n+=H,t=re,d&&n>=r.truncation.limit)break;continue}}}if($.lastIndex=t,$.test(e)){const h=$.lastIndex-t,m=r.truncation.countAnsiEscapeCodes?h:r.width.ansi;if(n+m>a&&(l=Math.min(l,t),n+m>r.truncation.limit)){d=!0;break}n+=m,t=$.lastIndex;continue}}const p=e.codePointAt(t);if(p===8203||p===65279||p>=8288&&p<=8292){t+=1;continue}if(p===9){if(n+r.width.tab>a&&(l=Math.min(l,t),n+r.width.tab>r.truncation.limit)){d=!0;break}n+=r.width.tab,t+=1;continue}if(N.lastIndex=t,N.test(e)){const h=(N.lastIndex-t)*r.width.regular;if(n+h>a){const m=Math.floor((a-n)/r.width.regular);if(l=Math.min(l,t+m),n+h>r.truncation.limit){d=!0;break}}n+=h,t=N.lastIndex;continue}if((p<=31||p>=127&&p<=159)&&(j.lastIndex=t,j.test(e))){const h=(j.lastIndex-t)*r.width.control;if(n+h>a&&(l=Math.min(l,t+Math.floor((a-n)/r.width.control)),n+h>r.truncation.limit)){d=!0;break}n+=h,t=j.lastIndex;continue}if(q.lastIndex=t,q.test(e)){if(n+r.width.emoji>a&&(l=Math.min(l,t),n+r.width.emoji>r.truncation.limit)){d=!0;break}n+=r.width.emoji,t=q.lastIndex;continue}const b=e.codePointAt(t)??0;if(ze(b)){t+=b>65535?2:1;continue}let f;if(s)f=qe(b,r);else switch(P(b)){case"control":{f=r.width.control;break}case"latin":{f=r.width.regular;break}case"wide":{f=r.width.wide;break}case"zero":{f=0;break}default:switch(A(b)){case"ambiguous":{f=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{f=r.width.fullWidth;break}case"wide":{f=r.width.wide;break}default:f=r.width.regular}}if(n+f>a&&(l=Math.min(l,t),n+f>r.truncation.limit)){d=!0;break}n+=f,t+=b>65535?2:1}let y=n,J=!1;return d&&r.truncation.limit>=r.truncation.ellipsisWidth&&(y=r.truncation.limit,J=!0),{ellipsed:J,index:d?l:o,truncated:d,width:y}},"getStringTruncatedWidth");var Ve=Object.defineProperty,Ye=u((e,i)=>Ve(e,"name",{value:i,configurable:!0}),"i$1"),De=Object.defineProperty,Je=Ye((e,i)=>De(e,"name",{value:i,configurable:!0}),"e"),Ue=Object.defineProperty,Ge=Je((e,i)=>Ue(e,"name",{value:i,configurable:!0}),"r");const Ke=Ge((e,i={})=>z(e,{...i,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,"getStringWidth");var Qe=Object.defineProperty,Xe=u((e,i)=>Qe(e,"name",{value:i,configurable:!0}),"s");const W=new Map,Ze=500,c=Xe(e=>{if(!e||e==="")return"";const i=W.get(e);if(i!==void 0)return i;const r=de(Object.assign([],{raw:[e]}));if(W.size>=Ze){const a=W.keys().next().value;a!==void 0&&W.delete(a)}return W.set(e,r),r},"templateFormat");var ei=Object.defineProperty,ii=u((e,i)=>ei(e,"name",{value:i,configurable:!0}),"t$1");const M=ii(()=>{const e=ue().CEREBRO_TERMINAL_WIDTH;if(e===void 0)return;const i=Number.parseInt(e,10);if(!(Number.isNaN(i)||i<=0))return i},"getTerminalWidth");var ri=Object.defineProperty,ti=u((e,i)=>ri(e,"name",{value:i,configurable:!0}),"t");class ie{static{u(this,"n")}static{ti(this,"BaseSection")}lines;constructor(){this.lines=[]}add(i){this.lines.push(i)}toString(){return this.lines.join(ce.EOL)}header(i){this.add(fe(i)),this.lines.push("")}}var ni=Object.defineProperty,k=u((e,i)=>ni(e,"name",{value:i,configurable:!0}),"g");const ai=k(e=>e!==void 0&&e>0?e:le().columns,"resolveTerminalWidth"),oi=k((e,i,r,a)=>{if(e.length===0||e.some(d=>d.length!==2))return;let o=0;for(const d of e){const w=d[0];if(w===void 0)continue;const y=Ke(w);y>o&&(o=y)}if(o===0)return;const s=r+a,t=o+s,n=20+s;if(t+n>i)return;const l=i-t;return[t,l]},"computeColumnWidths");class si extends ie{static{u(this,"S")}static{k(this,"ContentSection")}constructor(i){if(super(),i.header&&this.header(c(i.header)),i.content){if(i.raw)if(Array.isArray(i.content)&&i.content.every(r=>typeof r=="string"))i.content.forEach(r=>{Array.isArray(r)?r.forEach(a=>{this.add(c(a))}):this.add(c(r))});else if(typeof i.content=="string")this.add(c(i.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(i.content));this.add("")}}getContentLines(i){if(typeof i=="string"){const r=x({showHeader:!1,style:{border:E,paddingLeft:4,paddingRight:1},terminalWidth:M(),truncateOverflow:!1,wordWrap:!0});return r.addRow([c(i)]),r.toString()}if(Array.isArray(i)&&i.every(r=>typeof r=="string"||Array.isArray(r)&&r.every(a=>typeof a=="string"))){const r=ai(M()),a=k(n=>Array.isArray(n)?n.map(l=>c(l)):[c(n)],"formatRow"),o=i.map(n=>a(n)),s=oi(o,r,4,1),t=x({columnWidths:s,showHeader:!1,style:{border:E,paddingLeft:4,paddingRight:1},terminalWidth:r,truncateOverflow:!1,wordWrap:!0});return o.forEach(n=>{s!==void 0&&n.length===2?t.addRow([{content:n[0],wordWrap:!1},n[1]]):t.addRow(n)}),t.toString()}if(typeof i=="object"){const r=i;if(!r.options||!r.data)throw new Error(`Must have an "options" or "data" property
2
+ ${JSON.stringify(i)}`);const a=x({showHeader:!1,style:{border:E,paddingLeft:4,paddingRight:1},terminalWidth:M(),truncateOverflow:!1,wordWrap:!0});return r.data.forEach(o=>{Array.isArray(o)?a.addRow(o.map(s=>c(s))):a.addRow([c(o)])}),a.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
3
+
4
+ ${JSON.stringify(i)}`)}}var li=Object.defineProperty,di=u((e,i)=>li(e,"name",{value:i,configurable:!0}),"m");class ui extends ie{static{u(this,"O")}static{di(this,"OptionListSection")}constructor(i){super();let r=i.optionList??[];const a=Array.isArray(i.hide)?i.hide:[i.hide].filter(t=>typeof t=="string"),o=Array.isArray(i.group)?i.group:[i.group].filter(t=>typeof t=="string");a.length>0&&(r=r.filter(t=>!a.includes(t.name))),i.header&&this.header(c(i.header)),o.length>0&&(r=r.filter(t=>{const n=t,l=o.includes("_none")&&!n.group,d=n.group,w=this.intersect(Array.isArray(d)?d:[d],o);return l||w?t:void 0}));const s=x({showHeader:!1,style:{border:E,paddingLeft:2,paddingRight:1,...i.tableOptions?.style},terminalWidth:M()??i.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:i.tableOptions?.wordWrap??!0,...i.tableOptions});r.forEach(t=>{const n=t;s.addRow([this.getOptionNames(n,i.reverseNameOrder??!1,i.isArgument??!1),c(n.description)])}),this.add(s.toString()),this.lines.push("")}getOptionNames(i,r,a){if(!i.name)throw new TypeError("Invalid option definition, name is required.");let o=i.type?i.type.name.toLowerCase():"string";const s=i.multiple||i.lazyMultiple?"[]":"";o=c(i.typeLabel??`{underline ${o}${s}}`);let t;if(i.alias)if(i.name){const n=a?i.name:`{yellow --${i.name}}`;t=c(r?`{bold ${n}}, {bold -${i.alias}} ${o}`:`{bold -${i.alias}}, {bold ${n}} ${o}`)}else r?t=c(`{bold -${i.alias}} ${o}`):t=c(`{bold -${i.alias}} ${o}`);else t=c(`{bold ${a?i.name:`{yellow --${i.name}}`}} ${o}`);return t}intersect(i,r){return i.some(a=>r.includes(a))}}var ci=Object.defineProperty,fi=u((e,i)=>ci(e,"name",{value:i,configurable:!0}),"o");const Wi=fi(e=>(Array.isArray(e)?e:[e]).length===0?"":`
5
+ ${e.map(i=>i.optionList?new ui(i).toString():new si(i).toString()).join(`
6
+ `)}`,"commandLineUsage");export{c as f,Wi as p};