@optique/core 0.9.0-dev.211 → 0.9.0-dev.215

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.js CHANGED
@@ -6,7 +6,7 @@ import { bash, fish, nu, pwsh, zsh } from "./completion.js";
6
6
  import { multiple, optional, withDefault } from "./modifiers.js";
7
7
  import { string } from "./valueparser.js";
8
8
  import { argument, command, constant, flag, option } from "./primitives.js";
9
- import { getDocPage, parse, suggest } from "./parser.js";
9
+ import { getDocPage, parseAsync, parseSync, suggest, suggestAsync } from "./parser.js";
10
10
 
11
11
  //#region src/facade.ts
12
12
  /**
@@ -89,6 +89,11 @@ function createCompletionParser(mode, programName, availableShells, name = "both
89
89
  { description: message`Generate shell completion script.` }
90
90
  ];
91
91
  const completionOption = option(...completionOptionArgs);
92
+ const argsParser = withDefault(multiple(argument(string({ metavar: "ARG" }), { description: message`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).` })), []);
93
+ const optionParser = object({
94
+ shell: completionOption,
95
+ args: argsParser
96
+ });
92
97
  switch (mode) {
93
98
  case "command": return {
94
99
  completionCommand,
@@ -96,17 +101,11 @@ function createCompletionParser(mode, programName, availableShells, name = "both
96
101
  };
97
102
  case "option": return {
98
103
  completionCommand: null,
99
- completionOption: object({
100
- shell: completionOption,
101
- args: withDefault(multiple(argument(string({ metavar: "ARG" }), { description: message`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).` })), [])
102
- })
104
+ completionOption: optionParser
103
105
  };
104
106
  case "both": return {
105
107
  completionCommand,
106
- completionOption: object({
107
- shell: completionOption,
108
- args: withDefault(multiple(argument(string({ metavar: "ARG" }), { description: message`Command line arguments for completion suggestions (used by shell integration; you usually don't need to provide this).` })), [])
109
- })
108
+ completionOption: optionParser
110
109
  };
111
110
  }
112
111
  }
@@ -117,6 +116,7 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
117
116
  const parsers = [];
118
117
  if (helpParsers.helpOption) {
119
118
  const lenientHelpParser = {
119
+ $mode: "sync",
120
120
  $valueType: [],
121
121
  $stateType: [],
122
122
  priority: 200,
@@ -178,12 +178,11 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
178
178
  value: state
179
179
  };
180
180
  },
181
- suggest(_context, prefix) {
182
- if ("--help".startsWith(prefix)) return [{
181
+ *suggest(_context, prefix) {
182
+ if ("--help".startsWith(prefix)) yield {
183
183
  kind: "literal",
184
184
  text: "--help"
185
- }];
186
- return [];
185
+ };
187
186
  },
188
187
  getDocFragments(state) {
189
188
  return helpParsers.helpOption?.getDocFragments(state) ?? { fragments: [] };
@@ -193,6 +192,7 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
193
192
  }
194
193
  if (versionParsers.versionOption) {
195
194
  const lenientVersionParser = {
195
+ $mode: "sync",
196
196
  $valueType: [],
197
197
  $stateType: [],
198
198
  priority: 200,
@@ -246,12 +246,11 @@ function combineWithHelpVersion(originalParser, helpParsers, versionParsers, com
246
246
  value: state
247
247
  };
248
248
  },
249
- suggest(_context, prefix) {
250
- if ("--version".startsWith(prefix)) return [{
249
+ *suggest(_context, prefix) {
250
+ if ("--version".startsWith(prefix)) yield {
251
251
  kind: "literal",
252
252
  text: "--version"
253
- }];
254
- return [];
253
+ };
255
254
  },
256
255
  getDocFragments(state) {
257
256
  return versionParsers.versionOption?.getDocFragments(state) ?? { fragments: [] };
@@ -346,6 +345,20 @@ function classifyResult(result, args) {
346
345
  function handleCompletion(completionArgs, programName, parser, completionParser, stdout, stderr, onCompletion, onError, availableShells, colors, maxWidth, completionMode, completionName) {
347
346
  const shellName = completionArgs[0] || "";
348
347
  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
+ };
349
362
  if (!shellName) {
350
363
  stderr("Error: Missing shell name for completion.\n");
351
364
  if (completionParser) {
@@ -355,72 +368,43 @@ function handleCompletion(completionArgs, programName, parser, completionParser,
355
368
  maxWidth
356
369
  }));
357
370
  }
358
- try {
359
- return onError(1);
360
- } catch {
361
- return onError();
362
- }
371
+ if (parser.$mode === "async") return Promise.resolve(callOnError(1));
372
+ return callOnError(1);
363
373
  }
364
374
  const shell = availableShells[shellName];
365
375
  if (!shell) {
366
376
  const available = [];
367
- for (const shell$1 in availableShells) {
377
+ for (const name in availableShells) {
368
378
  if (available.length > 0) available.push(text(", "));
369
- available.push(value(shell$1));
379
+ available.push(value(name));
370
380
  }
371
381
  stderr(formatMessage(message`Error: Unsupported shell ${shellName}. Available shells: ${available}.`, {
372
382
  colors,
373
383
  quotes: !colors
374
384
  }));
375
- return onError(1);
385
+ if (parser.$mode === "async") return Promise.resolve(callOnError(1));
386
+ return callOnError(1);
376
387
  }
377
388
  if (args.length === 0) {
378
389
  const usePlural = completionName === "plural";
379
390
  const completionArg = completionMode === "option" ? usePlural ? "--completions" : "--completion" : usePlural ? "completions" : "completion";
380
391
  const script = shell.generateScript(programName, [completionArg, shellName]);
381
392
  stdout(script);
382
- } else {
383
- const suggestions = 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();
393
+ if (parser.$mode === "async") return Promise.resolve(callOnCompletion(0));
394
+ return callOnCompletion(0);
390
395
  }
396
+ if (parser.$mode === "async") return (async () => {
397
+ const suggestions$1 = await 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 = suggest(syncParser, args);
403
+ for (const chunk of shell.encodeSuggestions(suggestions)) stdout(chunk);
404
+ return callOnCompletion(0);
391
405
  }
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
- */
422
406
  function runParser(parser, programName, args, options = {}) {
423
- let { colors, maxWidth, showDefault, aboveError = "usage", onError = () => {
407
+ const { colors, maxWidth, showDefault, aboveError = "usage", onError = () => {
424
408
  throw new RunParserError("Failed to parse command line arguments.");
425
409
  }, stderr = console.error, stdout = console.log, brief, description, footer } = options;
426
410
  const helpMode = options.help?.mode ?? "option";
@@ -480,97 +464,155 @@ function runParser(parser, programName, args, options = {}) {
480
464
  }
481
465
  }
482
466
  const augmentedParser = help === "none" && version === "none" && completion === "none" ? parser : combineWithHelpVersion(parser, helpParsers, versionParsers, completionParsers);
483
- const result = 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);
508
- }
509
- if (versionAsCommand) {
510
- if (versionParsers.versionCommand) commandParsers.push(versionParsers.versionCommand);
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();
511
477
  }
512
- if (completionAsCommand) {
513
- if (completionParsers.completionCommand) commandParsers.push(completionParsers.completionCommand);
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 = longestMatch(commandParsers[0], commandParsers[1]);
501
+ else helpGeneratorParser = longestMatch(...commandParsers);
514
502
  }
515
- if (commandParsers.length === 1) helpGeneratorParser = commandParsers[0];
516
- else if (commandParsers.length === 2) helpGeneratorParser = longestMatch(commandParsers[0], commandParsers[1]);
517
- else helpGeneratorParser = longestMatch(...commandParsers);
518
- }
519
- const doc = 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
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(formatDocPage(programName, augmentedDoc, {
513
+ colors,
514
+ maxWidth,
515
+ showDefault
516
+ }));
517
+ }
518
+ try {
519
+ return onHelp(0);
520
+ } catch {
521
+ return onHelp();
522
+ }
527
523
  };
528
- stdout(formatDocPage(programName, augmentedDoc, {
529
- colors,
530
- maxWidth,
531
- showDefault
532
- }));
533
- }
534
- try {
535
- return onHelp(0);
536
- } catch {
537
- return onHelp();
524
+ const docOrPromise = getDocPage(helpGeneratorParser, classified.commands);
525
+ if (docOrPromise instanceof Promise) return docOrPromise.then(displayHelp);
526
+ return displayHelp(docOrPromise);
538
527
  }
539
- }
540
- case "error": {
541
- if (aboveError === "help") {
542
- const doc = 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(formatDocPage(programName, augmentedDoc, {
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(formatDocPage(programName, augmentedDoc, {
540
+ colors,
541
+ maxWidth,
542
+ showDefault
543
+ }));
544
+ }
545
+ if (effectiveAboveError === "usage") stderr(`Usage: ${indentLines(formatUsage(programName, augmentedParser.usage, {
546
+ colors,
547
+ maxWidth: maxWidth == null ? void 0 : maxWidth - 7,
548
+ expandCommands: true
549
+ }), 7)}`);
550
+ const errorMessage = formatMessage(classified.error, {
552
551
  colors,
553
- maxWidth,
554
- showDefault
555
- }));
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 = getDocPage(parserForDoc, args);
560
+ if (docOrPromise instanceof Promise) return docOrPromise.then((doc) => displayError(doc, aboveError));
561
+ return displayError(docOrPromise, aboveError);
556
562
  }
563
+ return displayError(void 0, aboveError);
557
564
  }
558
- if (aboveError === "usage") stderr(`Usage: ${indentLines(formatUsage(programName, augmentedParser.usage, {
559
- colors,
560
- maxWidth: maxWidth == null ? void 0 : maxWidth - 7,
561
- expandCommands: true
562
- }), 7)}`);
563
- const errorMessage = formatMessage(classified.error, {
564
- colors,
565
- quotes: !colors
566
- });
567
- stderr(`Error: ${errorMessage}`);
568
- return onError(1);
565
+ default: throw new RunParserError("Unexpected parse result type");
569
566
  }
570
- default: throw new RunParserError("Unexpected parse result type");
567
+ };
568
+ if (parser.$mode === "async") return parseAsync(augmentedParser, args).then(handleResult);
569
+ else {
570
+ const result = parseSync(augmentedParser, args);
571
+ return handleResult(result);
571
572
  }
572
573
  }
573
574
  /**
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
+ /**
574
616
  * @deprecated Use `runParser()` instead. This export will be removed in
575
617
  * a future major version. The name `run` conflicts with
576
618
  * `@optique/run`'s `run()` function, causing IDE autocomplete
@@ -597,4 +639,4 @@ function indentLines(text$1, indent) {
597
639
  }
598
640
 
599
641
  //#endregion
600
- export { RunError, RunParserError, run, runParser };
642
+ export { RunError, RunParserError, run, runParser, runParserAsync, runParserSync };
package/dist/index.cjs CHANGED
@@ -35,6 +35,8 @@ exports.formatMessage = require_message.formatMessage;
35
35
  exports.formatUsage = require_usage.formatUsage;
36
36
  exports.formatUsageTerm = require_usage.formatUsageTerm;
37
37
  exports.getDocPage = require_parser.getDocPage;
38
+ exports.getDocPageAsync = require_parser.getDocPageAsync;
39
+ exports.getDocPageSync = require_parser.getDocPageSync;
38
40
  exports.group = require_constructs.group;
39
41
  exports.integer = require_valueparser.integer;
40
42
  exports.isNonEmptyString = require_nonempty.isNonEmptyString;
@@ -55,12 +57,18 @@ exports.optionNames = require_message.optionNames;
55
57
  exports.optional = require_modifiers.optional;
56
58
  exports.or = require_constructs.or;
57
59
  exports.parse = require_parser.parse;
60
+ exports.parseAsync = require_parser.parseAsync;
61
+ exports.parseSync = require_parser.parseSync;
58
62
  exports.passThrough = require_primitives.passThrough;
59
63
  exports.pwsh = require_completion.pwsh;
60
64
  exports.run = require_facade.run;
61
65
  exports.runParser = require_facade.runParser;
66
+ exports.runParserAsync = require_facade.runParserAsync;
67
+ exports.runParserSync = require_facade.runParserSync;
62
68
  exports.string = require_valueparser.string;
63
69
  exports.suggest = require_parser.suggest;
70
+ exports.suggestAsync = require_parser.suggestAsync;
71
+ exports.suggestSync = require_parser.suggestSync;
64
72
  exports.text = require_message.text;
65
73
  exports.tuple = require_constructs.tuple;
66
74
  exports.url = require_valueparser.url;
package/dist/index.d.cts CHANGED
@@ -5,8 +5,8 @@ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, Doc
5
5
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, FloatOptions, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, float, integer, isValueParser, locale, string, url, uuid } from "./valueparser.cjs";
6
6
  import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, optional, withDefault } from "./modifiers.cjs";
7
7
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, PassThroughFormat, PassThroughOptions, argument, command, constant, flag, option, passThrough } from "./primitives.cjs";
8
- import { DocState, InferValue, Parser, ParserContext, ParserResult, Result, Suggestion, getDocPage, parse, suggest } from "./parser.cjs";
8
+ import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, ModeValue, Parser, ParserContext, ParserResult, Result, Suggestion, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.cjs";
9
9
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.cjs";
10
10
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
11
- import { RunError, RunOptions, RunParserError, run, runParser } from "./facade.cjs";
12
- export { ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DuplicateOptionError, FlagErrorOptions, FlagOptions, FloatOptions, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Message, MessageFormatOptions, MessageTerm, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OrErrorOptions, OrOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, RunError, RunOptions, RunParserError, ShellCompletion, ShowDefaultOptions, StringOptions, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, WithDefaultOptions, argument, bash, choice, command, commandLine, concat, conditional, constant, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isNonEmptyString, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, passThrough, pwsh, run, runParser, string, suggest, text, tuple, url, uuid, value, values, withDefault, zsh };
11
+ import { RunError, RunOptions, RunParserError, run, runParser, runParserAsync, runParserSync } from "./facade.cjs";
12
+ export { ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DuplicateOptionError, FlagErrorOptions, FlagOptions, FloatOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Message, MessageFormatOptions, MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OrErrorOptions, OrOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, RunError, RunOptions, RunParserError, ShellCompletion, ShowDefaultOptions, StringOptions, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, WithDefaultOptions, argument, bash, choice, command, commandLine, concat, conditional, constant, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, getDocPageAsync, getDocPageSync, group, integer, isNonEmptyString, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, pwsh, run, runParser, runParserAsync, runParserSync, string, suggest, suggestAsync, suggestSync, text, tuple, url, uuid, value, values, withDefault, zsh };
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, Doc
5
5
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, FloatOptions, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, float, integer, isValueParser, locale, string, url, uuid } from "./valueparser.js";
6
6
  import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, optional, withDefault } from "./modifiers.js";
7
7
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, PassThroughFormat, PassThroughOptions, argument, command, constant, flag, option, passThrough } from "./primitives.js";
8
- import { DocState, InferValue, Parser, ParserContext, ParserResult, Result, Suggestion, getDocPage, parse, suggest } from "./parser.js";
8
+ import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, ModeValue, Parser, ParserContext, ParserResult, Result, Suggestion, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.js";
9
9
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
10
10
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
11
- import { RunError, RunOptions, RunParserError, run, runParser } from "./facade.js";
12
- export { ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DuplicateOptionError, FlagErrorOptions, FlagOptions, FloatOptions, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Message, MessageFormatOptions, MessageTerm, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OrErrorOptions, OrOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, RunError, RunOptions, RunParserError, ShellCompletion, ShowDefaultOptions, StringOptions, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, WithDefaultOptions, argument, bash, choice, command, commandLine, concat, conditional, constant, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isNonEmptyString, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, passThrough, pwsh, run, runParser, string, suggest, text, tuple, url, uuid, value, values, withDefault, zsh };
11
+ import { RunError, RunOptions, RunParserError, run, runParser, runParserAsync, runParserSync } from "./facade.js";
12
+ export { ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DuplicateOptionError, FlagErrorOptions, FlagOptions, FloatOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Message, MessageFormatOptions, MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OrErrorOptions, OrOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, RunError, RunOptions, RunParserError, ShellCompletion, ShowDefaultOptions, StringOptions, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, WithDefaultOptions, argument, bash, choice, command, commandLine, concat, conditional, constant, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, getDocPageAsync, getDocPageSync, group, integer, isNonEmptyString, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, pwsh, run, runParser, runParserAsync, runParserSync, string, suggest, suggestAsync, suggestSync, text, tuple, url, uuid, value, values, withDefault, zsh };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { WithDefaultError, map, multiple, optional, withDefault } from "./modifi
7
7
  import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
8
8
  import { choice, float, integer, isValueParser, locale, string, url, uuid } from "./valueparser.js";
9
9
  import { argument, command, constant, flag, option, passThrough } from "./primitives.js";
10
- import { getDocPage, parse, suggest } from "./parser.js";
11
- import { RunError, RunParserError, run, runParser } from "./facade.js";
10
+ import { getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.js";
11
+ import { RunError, RunParserError, run, runParser, runParserAsync, runParserSync } from "./facade.js";
12
12
 
13
- export { DuplicateOptionError, RunError, RunParserError, WithDefaultError, argument, bash, choice, command, commandLine, concat, conditional, constant, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isNonEmptyString, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, passThrough, pwsh, run, runParser, string, suggest, text, tuple, url, uuid, value, values, withDefault, zsh };
13
+ export { DuplicateOptionError, RunError, RunParserError, WithDefaultError, argument, bash, choice, command, commandLine, concat, conditional, constant, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, getDocPageAsync, getDocPageSync, group, integer, isNonEmptyString, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, pwsh, run, runParser, runParserAsync, runParserSync, string, suggest, suggestAsync, suggestSync, text, tuple, url, uuid, value, values, withDefault, zsh };