@optique/core 0.9.0-dev.217 → 0.9.0-dev.224

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/dist/facade.cjs CHANGED
@@ -89,11 +89,6 @@ function createCompletionParser(mode, programName, availableShells, name = "both
89
89
  { description: require_message.message`Generate shell completion script.` }
90
90
  ];
91
91
  const completionOption = require_primitives.option(...completionOptionArgs);
92
- const argsParser = require_modifiers.withDefault(require_modifiers.multiple(require_primitives.argument(require_valueparser.string({ metavar: "ARG" }), { description: require_message.message`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).` })), []);
93
- const optionParser = require_constructs.object({
94
- shell: completionOption,
95
- args: argsParser
96
- });
97
92
  switch (mode) {
98
93
  case "command": return {
99
94
  completionCommand,
@@ -101,11 +96,17 @@ function createCompletionParser(mode, programName, availableShells, name = "both
101
96
  };
102
97
  case "option": return {
103
98
  completionCommand: null,
104
- completionOption: optionParser
99
+ completionOption: require_constructs.object({
100
+ shell: completionOption,
101
+ args: require_modifiers.withDefault(require_modifiers.multiple(require_primitives.argument(require_valueparser.string({ metavar: "ARG" }), { description: require_message.message`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).` })), [])
102
+ })
105
103
  };
106
104
  case "both": return {
107
105
  completionCommand,
108
- completionOption: optionParser
106
+ completionOption: require_constructs.object({
107
+ shell: completionOption,
108
+ args: require_modifiers.withDefault(require_modifiers.multiple(require_primitives.argument(require_valueparser.string({ metavar: "ARG" }), { description: require_message.message`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).` })), [])
109
+ })
109
110
  };
110
111
  }
111
112
  }
@@ -116,7 +117,6 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
116
117
  const parsers = [];
117
118
  if (helpParsers.helpOption) {
118
119
  const lenientHelpParser = {
119
- $mode: "sync",
120
120
  $valueType: [],
121
121
  $stateType: [],
122
122
  priority: 200,
@@ -178,11 +178,12 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
178
178
  value: state
179
179
  };
180
180
  },
181
- *suggest(_context, prefix) {
182
- if ("--help".startsWith(prefix)) yield {
181
+ suggest(_context, prefix) {
182
+ if ("--help".startsWith(prefix)) return [{
183
183
  kind: "literal",
184
184
  text: "--help"
185
- };
185
+ }];
186
+ return [];
186
187
  },
187
188
  getDocFragments(state) {
188
189
  return helpParsers.helpOption?.getDocFragments(state) ?? { fragments: [] };
@@ -192,7 +193,6 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
192
193
  }
193
194
  if (versionParsers.versionOption) {
194
195
  const lenientVersionParser = {
195
- $mode: "sync",
196
196
  $valueType: [],
197
197
  $stateType: [],
198
198
  priority: 200,
@@ -246,11 +246,12 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
246
246
  value: state
247
247
  };
248
248
  },
249
- *suggest(_context, prefix) {
250
- if ("--version".startsWith(prefix)) yield {
249
+ suggest(_context, prefix) {
250
+ if ("--version".startsWith(prefix)) return [{
251
251
  kind: "literal",
252
252
  text: "--version"
253
- };
253
+ }];
254
+ return [];
254
255
  },
255
256
  getDocFragments(state) {
256
257
  return versionParsers.versionOption?.getDocFragments(state) ?? { fragments: [] };
@@ -345,20 +346,6 @@ function classifyResult(result, args) {
345
346
  function handleCompletion(completionArgs, programName, parser, completionParser, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode, completionName) {
346
347
  const shellName = completionArgs[0] || "";
347
348
  const args = completionArgs.slice(1);
348
- const callOnError = (code) => {
349
- try {
350
- return onError(code);
351
- } catch {
352
- return onError();
353
- }
354
- };
355
- const callOnCompletion = (code) => {
356
- try {
357
- return onCompletion(code);
358
- } catch {
359
- return onCompletion();
360
- }
361
- };
362
349
  if (!shellName) {
363
350
  stderr("Error: Missing shell name for completion.\n");
364
351
  if (completionParser) {
@@ -368,43 +355,72 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
368
355
  maxWidth
369
356
  }));
370
357
  }
371
- if (parser.$mode === "async") return Promise.resolve(callOnError(1));
372
- return callOnError(1);
358
+ try {
359
+ return onError(1);
360
+ } catch {
361
+ return onError();
362
+ }
373
363
  }
374
364
  const shell = availableShells[shellName];
375
365
  if (!shell) {
376
366
  const available = [];
377
- for (const name in availableShells) {
367
+ for (const shell$1 in availableShells) {
378
368
  if (available.length > 0) available.push(require_message.text(", "));
379
- available.push(require_message.value(name));
369
+ available.push(require_message.value(shell$1));
380
370
  }
381
371
  stderr(require_message.formatMessage(require_message.message`Error: Unsupported shell ${shellName}. Available shells: ${available}.`, {
382
372
  colors,
383
373
  quotes: !colors
384
374
  }));
385
- if (parser.$mode === "async") return Promise.resolve(callOnError(1));
386
- return callOnError(1);
375
+ return onError(1);
387
376
  }
388
377
  if (args.length === 0) {
389
378
  const usePlural = completionName === "plural";
390
379
  const completionArg = completionMode === "option" ? usePlural ? "--completions" : "--completion" : usePlural ? "completions" : "completion";
391
380
  const script = shell.generateScript(programName, [completionArg, shellName]);
392
381
  stdout(script);
393
- if (parser.$mode === "async") return Promise.resolve(callOnCompletion(0));
394
- return callOnCompletion(0);
382
+ } else {
383
+ const suggestions = require_parser.suggest(parser, args);
384
+ for (const chunk of shell.encodeSuggestions(suggestions)) stdout(chunk);
385
+ }
386
+ try {
387
+ return onCompletion(0);
388
+ } catch {
389
+ return onCompletion();
395
390
  }
396
- if (parser.$mode === "async") return (async () => {
397
- const suggestions$1 = await require_parser.suggestAsync(parser, args);
398
- for (const chunk of shell.encodeSuggestions(suggestions$1)) stdout(chunk);
399
- return callOnCompletion(0);
400
- })();
401
- const syncParser = parser;
402
- const suggestions = require_parser.suggest(syncParser, args);
403
- for (const chunk of shell.encodeSuggestions(suggestions)) stdout(chunk);
404
- return callOnCompletion(0);
405
391
  }
392
+ /**
393
+ * Runs a parser against command-line arguments with built-in help and error
394
+ * handling.
395
+ *
396
+ * This function provides a complete CLI interface by automatically handling
397
+ * help commands/options and displaying formatted error messages with usage
398
+ * information when parsing fails. It augments the provided parser with help
399
+ * functionality based on the configuration options.
400
+ *
401
+ * The function will:
402
+ *
403
+ * 1. Add help command/option support (unless disabled)
404
+ * 2. Parse the provided arguments
405
+ * 3. Display help if requested
406
+ * 4. Show formatted error messages with usage/help info on parse failures
407
+ * 5. Return the parsed result or invoke the appropriate callback
408
+ *
409
+ * @template TParser The parser type being run.
410
+ * @template THelp Return type when help is shown (defaults to `void`).
411
+ * @template TError Return type when an error occurs (defaults to `never`).
412
+ * @param parser The parser to run against the command-line arguments.
413
+ * @param programName Name of the program used in usage and help output.
414
+ * @param args Command-line arguments to parse (typically from
415
+ * `process.argv.slice(2)` on Node.js or `Deno.args` on Deno).
416
+ * @param options Configuration options for output formatting and callbacks.
417
+ * @returns The parsed result value, or the return value of `onHelp`/`onError`
418
+ * callbacks.
419
+ * @throws {RunParserError} When parsing fails and no `onError` callback is
420
+ * provided.
421
+ */
406
422
  function runParser(parser, programName, args, options = {}) {
407
- const { colors, maxWidth, showDefault, aboveError = "usage", onError = () => {
423
+ let { colors, maxWidth, showDefault, aboveError = "usage", onError = () => {
408
424
  throw new RunParserError("Failed to parse command line arguments.");
409
425
  }, stderr = console.error, stdout = console.log, brief, description, footer } = options;
410
426
  const helpMode = options.help?.mode ?? "option";
@@ -464,155 +480,97 @@ function runParser(parser, programName, args, options = {}) {
464
480
  }
465
481
  }
466
482
  const augmentedParser = help === "none" && version === "none" && completion === "none" ? parser : combineWithHelpVersion(parser, helpParsers, versionParsers, completionParsers);
467
- const handleResult = (result) => {
468
- const classified = classifyResult(result, args);
469
- switch (classified.type) {
470
- case "success": return classified.value;
471
- case "version":
472
- stdout(versionValue);
473
- try {
474
- return onVersion(0);
475
- } catch {
476
- return onVersion();
483
+ const result = require_parser.parse(augmentedParser, args);
484
+ const classified = classifyResult(result, args);
485
+ switch (classified.type) {
486
+ case "success": return classified.value;
487
+ case "version":
488
+ stdout(versionValue);
489
+ try {
490
+ return onVersion(0);
491
+ } catch {
492
+ return onVersion();
493
+ }
494
+ case "completion": throw new RunParserError("Completion should be handled by early return");
495
+ case "help": {
496
+ let helpGeneratorParser;
497
+ const helpAsCommand = help === "command" || help === "both";
498
+ const versionAsCommand = version === "command" || version === "both";
499
+ const completionAsCommand = completion === "command" || completion === "both";
500
+ const requestedCommand = classified.commands[0];
501
+ if ((requestedCommand === "completion" || requestedCommand === "completions") && completionAsCommand && completionParsers.completionCommand) helpGeneratorParser = completionParsers.completionCommand;
502
+ else if (requestedCommand === "help" && helpAsCommand && helpParsers.helpCommand) helpGeneratorParser = helpParsers.helpCommand;
503
+ else if (requestedCommand === "version" && versionAsCommand && versionParsers.versionCommand) helpGeneratorParser = versionParsers.versionCommand;
504
+ else {
505
+ const commandParsers = [parser];
506
+ if (helpAsCommand) {
507
+ if (helpParsers.helpCommand) commandParsers.push(helpParsers.helpCommand);
477
508
  }
478
- case "completion": throw new RunParserError("Completion should be handled by early return");
479
- case "help": {
480
- let helpGeneratorParser;
481
- const helpAsCommand = help === "command" || help === "both";
482
- const versionAsCommand = version === "command" || version === "both";
483
- const completionAsCommand = completion === "command" || completion === "both";
484
- const requestedCommand = classified.commands[0];
485
- if ((requestedCommand === "completion" || requestedCommand === "completions") && completionAsCommand && completionParsers.completionCommand) helpGeneratorParser = completionParsers.completionCommand;
486
- else if (requestedCommand === "help" && helpAsCommand && helpParsers.helpCommand) helpGeneratorParser = helpParsers.helpCommand;
487
- else if (requestedCommand === "version" && versionAsCommand && versionParsers.versionCommand) helpGeneratorParser = versionParsers.versionCommand;
488
- else {
489
- const commandParsers = [parser];
490
- if (helpAsCommand) {
491
- if (helpParsers.helpCommand) commandParsers.push(helpParsers.helpCommand);
492
- }
493
- if (versionAsCommand) {
494
- if (versionParsers.versionCommand) commandParsers.push(versionParsers.versionCommand);
495
- }
496
- if (completionAsCommand) {
497
- if (completionParsers.completionCommand) commandParsers.push(completionParsers.completionCommand);
498
- }
499
- if (commandParsers.length === 1) helpGeneratorParser = commandParsers[0];
500
- else if (commandParsers.length === 2) helpGeneratorParser = require_constructs.longestMatch(commandParsers[0], commandParsers[1]);
501
- else helpGeneratorParser = require_constructs.longestMatch(...commandParsers);
509
+ if (versionAsCommand) {
510
+ if (versionParsers.versionCommand) commandParsers.push(versionParsers.versionCommand);
502
511
  }
503
- const displayHelp = (doc) => {
504
- if (doc != null) {
505
- const isMetaCommandHelp = (completionName === "singular" || completionName === "both" ? requestedCommand === "completion" : false) || (completionName === "plural" || completionName === "both" ? requestedCommand === "completions" : false) || requestedCommand === "help" || requestedCommand === "version";
506
- const augmentedDoc = {
507
- ...doc,
508
- brief: !isMetaCommandHelp ? brief ?? doc.brief : doc.brief,
509
- description: !isMetaCommandHelp ? description ?? doc.description : doc.description,
510
- footer: !isMetaCommandHelp ? footer ?? doc.footer : doc.footer
511
- };
512
- stdout(require_doc.formatDocPage(programName, augmentedDoc, {
513
- colors,
514
- maxWidth,
515
- showDefault
516
- }));
517
- }
518
- try {
519
- return onHelp(0);
520
- } catch {
521
- return onHelp();
522
- }
512
+ if (completionAsCommand) {
513
+ if (completionParsers.completionCommand) commandParsers.push(completionParsers.completionCommand);
514
+ }
515
+ if (commandParsers.length === 1) helpGeneratorParser = commandParsers[0];
516
+ else if (commandParsers.length === 2) helpGeneratorParser = require_constructs.longestMatch(commandParsers[0], commandParsers[1]);
517
+ else helpGeneratorParser = require_constructs.longestMatch(...commandParsers);
518
+ }
519
+ const doc = require_parser.getDocPage(helpGeneratorParser, classified.commands);
520
+ if (doc != null) {
521
+ const isMetaCommandHelp = (completionName === "singular" || completionName === "both" ? requestedCommand === "completion" : false) || (completionName === "plural" || completionName === "both" ? requestedCommand === "completions" : false) || requestedCommand === "help" || requestedCommand === "version";
522
+ const augmentedDoc = {
523
+ ...doc,
524
+ brief: !isMetaCommandHelp ? brief ?? doc.brief : doc.brief,
525
+ description: !isMetaCommandHelp ? description ?? doc.description : doc.description,
526
+ footer: !isMetaCommandHelp ? footer ?? doc.footer : doc.footer
523
527
  };
524
- const docOrPromise = require_parser.getDocPage(helpGeneratorParser, classified.commands);
525
- if (docOrPromise instanceof Promise) return docOrPromise.then(displayHelp);
526
- return displayHelp(docOrPromise);
528
+ stdout(require_doc.formatDocPage(programName, augmentedDoc, {
529
+ colors,
530
+ maxWidth,
531
+ showDefault
532
+ }));
527
533
  }
528
- case "error": {
529
- const displayError = (doc, currentAboveError) => {
530
- let effectiveAboveError = currentAboveError;
531
- if (effectiveAboveError === "help") if (doc == null) effectiveAboveError = "usage";
532
- else {
533
- const augmentedDoc = {
534
- ...doc,
535
- brief: brief ?? doc.brief,
536
- description: description ?? doc.description,
537
- footer: footer ?? doc.footer
538
- };
539
- stderr(require_doc.formatDocPage(programName, augmentedDoc, {
540
- colors,
541
- maxWidth,
542
- showDefault
543
- }));
544
- }
545
- if (effectiveAboveError === "usage") stderr(`Usage: ${indentLines(require_usage.formatUsage(programName, augmentedParser.usage, {
546
- colors,
547
- maxWidth: maxWidth == null ? void 0 : maxWidth - 7,
548
- expandCommands: true
549
- }), 7)}`);
550
- const errorMessage = require_message.formatMessage(classified.error, {
534
+ try {
535
+ return onHelp(0);
536
+ } catch {
537
+ return onHelp();
538
+ }
539
+ }
540
+ case "error": {
541
+ if (aboveError === "help") {
542
+ const doc = require_parser.getDocPage(args.length < 1 ? augmentedParser : parser, args);
543
+ if (doc == null) aboveError = "usage";
544
+ else {
545
+ const augmentedDoc = {
546
+ ...doc,
547
+ brief: brief ?? doc.brief,
548
+ description: description ?? doc.description,
549
+ footer: footer ?? doc.footer
550
+ };
551
+ stderr(require_doc.formatDocPage(programName, augmentedDoc, {
551
552
  colors,
552
- quotes: !colors
553
- });
554
- stderr(`Error: ${errorMessage}`);
555
- return onError(1);
556
- };
557
- if (aboveError === "help") {
558
- const parserForDoc = args.length < 1 ? augmentedParser : parser;
559
- const docOrPromise = require_parser.getDocPage(parserForDoc, args);
560
- if (docOrPromise instanceof Promise) return docOrPromise.then((doc) => displayError(doc, aboveError));
561
- return displayError(docOrPromise, aboveError);
553
+ maxWidth,
554
+ showDefault
555
+ }));
562
556
  }
563
- return displayError(void 0, aboveError);
564
557
  }
565
- default: throw new RunParserError("Unexpected parse result type");
558
+ if (aboveError === "usage") stderr(`Usage: ${indentLines(require_usage.formatUsage(programName, augmentedParser.usage, {
559
+ colors,
560
+ maxWidth: maxWidth == null ? void 0 : maxWidth - 7,
561
+ expandCommands: true
562
+ }), 7)}`);
563
+ const errorMessage = require_message.formatMessage(classified.error, {
564
+ colors,
565
+ quotes: !colors
566
+ });
567
+ stderr(`Error: ${errorMessage}`);
568
+ return onError(1);
566
569
  }
567
- };
568
- if (parser.$mode === "async") return require_parser.parseAsync(augmentedParser, args).then(handleResult);
569
- else {
570
- const result = require_parser.parseSync(augmentedParser, args);
571
- return handleResult(result);
570
+ default: throw new RunParserError("Unexpected parse result type");
572
571
  }
573
572
  }
574
573
  /**
575
- * Runs a synchronous command-line parser with the given options.
576
- *
577
- * This is a type-safe version of {@link runParser} that only accepts sync
578
- * parsers. Use this when you know your parser is sync-only to get direct
579
- * return values without Promise wrappers.
580
- *
581
- * @template TParser The sync parser type being executed.
582
- * @template THelp The return type of the onHelp callback.
583
- * @template TError The return type of the onError callback.
584
- * @param parser The synchronous command-line parser to execute.
585
- * @param programName The name of the program for help messages.
586
- * @param args The command-line arguments to parse.
587
- * @param options Configuration options for customizing behavior.
588
- * @returns The parsed result if successful.
589
- * @since 0.9.0
590
- */
591
- function runParserSync(parser, programName, args, options) {
592
- return runParser(parser, programName, args, options);
593
- }
594
- /**
595
- * Runs any command-line parser asynchronously with the given options.
596
- *
597
- * This function accepts parsers of any mode (sync or async) and always
598
- * returns a Promise. Use this when working with parsers that may contain
599
- * async value parsers.
600
- *
601
- * @template TParser The parser type being executed.
602
- * @template THelp The return type of the onHelp callback.
603
- * @template TError The return type of the onError callback.
604
- * @param parser The command-line parser to execute.
605
- * @param programName The name of the program for help messages.
606
- * @param args The command-line arguments to parse.
607
- * @param options Configuration options for customizing behavior.
608
- * @returns A Promise of the parsed result if successful.
609
- * @since 0.9.0
610
- */
611
- function runParserAsync(parser, programName, args, options) {
612
- const result = runParser(parser, programName, args, options);
613
- return Promise.resolve(result);
614
- }
615
- /**
616
574
  * @deprecated Use `runParser()` instead. This export will be removed in
617
575
  * a future major version. The name `run` conflicts with
618
576
  * `@optique/run`'s `run()` function, causing IDE autocomplete
@@ -642,6 +600,4 @@ function indentLines(text$1, indent) {
642
600
  exports.RunError = RunError;
643
601
  exports.RunParserError = RunParserError;
644
602
  exports.run = run;
645
- exports.runParser = runParser;
646
- exports.runParserAsync = runParserAsync;
647
- exports.runParserSync = runParserSync;
603
+ exports.runParser = runParser;
package/dist/facade.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Message } from "./message.cjs";
2
2
  import { ShowDefaultOptions } from "./doc.cjs";
3
- import { InferMode, InferValue, Mode, ModeValue, Parser } from "./parser.cjs";
3
+ import { InferValue, Parser } from "./parser.cjs";
4
4
  import { ShellCompletion } from "./completion.cjs";
5
5
 
6
6
  //#region src/facade.d.ts
@@ -214,45 +214,7 @@ interface RunOptions<THelp, TError> {
214
214
  * @throws {RunParserError} When parsing fails and no `onError` callback is
215
215
  * provided.
216
216
  */
217
- declare function runParser<TParser extends Parser<"sync", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
218
- declare function runParser<TParser extends Parser<"async", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): Promise<InferValue<TParser>>;
219
- declare function runParser<TParser extends Parser<Mode, unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): ModeValue<InferMode<TParser>, InferValue<TParser>>;
220
- /**
221
- * Runs a synchronous command-line parser with the given options.
222
- *
223
- * This is a type-safe version of {@link runParser} that only accepts sync
224
- * parsers. Use this when you know your parser is sync-only to get direct
225
- * return values without Promise wrappers.
226
- *
227
- * @template TParser The sync parser type being executed.
228
- * @template THelp The return type of the onHelp callback.
229
- * @template TError The return type of the onError callback.
230
- * @param parser The synchronous command-line parser to execute.
231
- * @param programName The name of the program for help messages.
232
- * @param args The command-line arguments to parse.
233
- * @param options Configuration options for customizing behavior.
234
- * @returns The parsed result if successful.
235
- * @since 0.9.0
236
- */
237
- declare function runParserSync<TParser extends Parser<"sync", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
238
- /**
239
- * Runs any command-line parser asynchronously with the given options.
240
- *
241
- * This function accepts parsers of any mode (sync or async) and always
242
- * returns a Promise. Use this when working with parsers that may contain
243
- * async value parsers.
244
- *
245
- * @template TParser The parser type being executed.
246
- * @template THelp The return type of the onHelp callback.
247
- * @template TError The return type of the onError callback.
248
- * @param parser The command-line parser to execute.
249
- * @param programName The name of the program for help messages.
250
- * @param args The command-line arguments to parse.
251
- * @param options Configuration options for customizing behavior.
252
- * @returns A Promise of the parsed result if successful.
253
- * @since 0.9.0
254
- */
255
- declare function runParserAsync<TParser extends Parser<Mode, unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): Promise<InferValue<TParser>>;
217
+ declare function runParser<TParser extends Parser<unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
256
218
  /**
257
219
  * @deprecated Use `runParser()` instead. This export will be removed in
258
220
  * a future major version. The name `run` conflicts with
@@ -273,4 +235,4 @@ declare class RunParserError extends Error {
273
235
  */
274
236
  declare const RunError: typeof RunParserError;
275
237
  //#endregion
276
- export { RunError, RunOptions, RunParserError, run, runParser, runParserAsync, runParserSync };
238
+ export { RunError, RunOptions, RunParserError, run, runParser };
package/dist/facade.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Message } from "./message.js";
2
2
  import { ShowDefaultOptions } from "./doc.js";
3
- import { InferMode, InferValue, Mode, ModeValue, Parser } from "./parser.js";
3
+ import { InferValue, Parser } from "./parser.js";
4
4
  import { ShellCompletion } from "./completion.js";
5
5
 
6
6
  //#region src/facade.d.ts
@@ -214,45 +214,7 @@ interface RunOptions<THelp, TError> {
214
214
  * @throws {RunParserError} When parsing fails and no `onError` callback is
215
215
  * provided.
216
216
  */
217
- declare function runParser<TParser extends Parser<"sync", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
218
- declare function runParser<TParser extends Parser<"async", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): Promise<InferValue<TParser>>;
219
- declare function runParser<TParser extends Parser<Mode, unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): ModeValue<InferMode<TParser>, InferValue<TParser>>;
220
- /**
221
- * Runs a synchronous command-line parser with the given options.
222
- *
223
- * This is a type-safe version of {@link runParser} that only accepts sync
224
- * parsers. Use this when you know your parser is sync-only to get direct
225
- * return values without Promise wrappers.
226
- *
227
- * @template TParser The sync parser type being executed.
228
- * @template THelp The return type of the onHelp callback.
229
- * @template TError The return type of the onError callback.
230
- * @param parser The synchronous command-line parser to execute.
231
- * @param programName The name of the program for help messages.
232
- * @param args The command-line arguments to parse.
233
- * @param options Configuration options for customizing behavior.
234
- * @returns The parsed result if successful.
235
- * @since 0.9.0
236
- */
237
- declare function runParserSync<TParser extends Parser<"sync", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
238
- /**
239
- * Runs any command-line parser asynchronously with the given options.
240
- *
241
- * This function accepts parsers of any mode (sync or async) and always
242
- * returns a Promise. Use this when working with parsers that may contain
243
- * async value parsers.
244
- *
245
- * @template TParser The parser type being executed.
246
- * @template THelp The return type of the onHelp callback.
247
- * @template TError The return type of the onError callback.
248
- * @param parser The command-line parser to execute.
249
- * @param programName The name of the program for help messages.
250
- * @param args The command-line arguments to parse.
251
- * @param options Configuration options for customizing behavior.
252
- * @returns A Promise of the parsed result if successful.
253
- * @since 0.9.0
254
- */
255
- declare function runParserAsync<TParser extends Parser<Mode, unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): Promise<InferValue<TParser>>;
217
+ declare function runParser<TParser extends Parser<unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
256
218
  /**
257
219
  * @deprecated Use `runParser()` instead. This export will be removed in
258
220
  * a future major version. The name `run` conflicts with
@@ -273,4 +235,4 @@ declare class RunParserError extends Error {
273
235
  */
274
236
  declare const RunError: typeof RunParserError;
275
237
  //#endregion
276
- export { RunError, RunOptions, RunParserError, run, runParser, runParserAsync, runParserSync };
238
+ export { RunError, RunOptions, RunParserError, run, runParser };