@optique/core 1.3.0-dev.2488 → 1.3.0-dev.2491

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
@@ -98,24 +98,6 @@ function prepareParsedForContexts(parsed, deferred, deferredKeys) {
98
98
  function isBufferUnchanged(previous, current) {
99
99
  return current.length > 0 && current.length === previous.length && current.every((item, i) => item === previous[i]);
100
100
  }
101
- function getFailureProgress(args, buffer, consumedInStep) {
102
- return {
103
- remainingArgs: buffer.slice(consumedInStep),
104
- consumedCount: args.length - buffer.length + consumedInStep
105
- };
106
- }
107
- function createParseExec(parser) {
108
- return {
109
- usage: parser.usage,
110
- phase: "parse",
111
- path: [],
112
- commandPath: [],
113
- trace: require_input_trace.createInputTrace()
114
- };
115
- }
116
- function getCommandPath(exec) {
117
- return exec?.commandPath ?? [];
118
- }
119
101
  const effectfulSessionOptionsKey = Symbol("@optique/core/facade/effectfulSessionOptionsKey");
120
102
  function getEffectfulSessionOption(options) {
121
103
  return options[effectfulSessionOptionsKey];
@@ -152,124 +134,6 @@ function createRunWithSessions() {
152
134
  finalSession
153
135
  };
154
136
  }
155
- function createCompleteExec(exec, context, session) {
156
- const runtime = require_dependency_runtime.createDependencyRuntimeContext();
157
- return {
158
- ...exec,
159
- phase: "complete",
160
- dependencyRuntime: runtime,
161
- dependencyRegistry: runtime.registry,
162
- commandPath: getCommandPath(context.exec) ?? exec.commandPath,
163
- trace: context.exec?.trace ?? context.trace ?? exec.trace,
164
- effectfulCompletionSession: session ?? require_internal_parser.createEffectfulCompletionSession()
165
- };
166
- }
167
- function attemptParseSync(parser, args, mode = "complete", session) {
168
- const shouldUnwrapAnnotatedValue = require_internal_annotations.isInjectedAnnotationWrapper(parser.initialState);
169
- const exec = createParseExec(parser);
170
- let context = require_internal_parser.createParserContext({
171
- buffer: args,
172
- state: parser.initialState,
173
- optionsTerminated: false
174
- }, exec);
175
- do {
176
- const result = parser.parse(context);
177
- if (!result.success) {
178
- const progress = getFailureProgress(args, context.buffer, result.consumed);
179
- return {
180
- kind: "failure",
181
- error: result.error,
182
- remainingArgs: progress.remainingArgs,
183
- consumedCount: progress.consumedCount,
184
- optionsTerminated: context.optionsTerminated,
185
- commandPath: getCommandPath(context.exec)
186
- };
187
- }
188
- const previousBuffer = context.buffer;
189
- context = result.next;
190
- if (isBufferUnchanged(previousBuffer, context.buffer)) {
191
- const progress = getFailureProgress(args, previousBuffer, result.consumed.length);
192
- return {
193
- kind: "failure",
194
- error: require_message.message`Unexpected option or argument: ${context.buffer[0]}.`,
195
- remainingArgs: progress.remainingArgs,
196
- consumedCount: progress.consumedCount,
197
- optionsTerminated: context.optionsTerminated,
198
- commandPath: getCommandPath(context.exec)
199
- };
200
- }
201
- } while (context.buffer.length > 0);
202
- if (mode === "parse-only") return {
203
- kind: "success",
204
- value: void 0
205
- };
206
- const endResult = parser.complete(context.state, createCompleteExec(exec, context, session));
207
- if (!endResult.success) return {
208
- kind: "failure",
209
- error: endResult.error,
210
- remainingArgs: [],
211
- consumedCount: args.length,
212
- optionsTerminated: context.optionsTerminated,
213
- commandPath: getCommandPath(context.exec)
214
- };
215
- return {
216
- kind: "success",
217
- value: shouldUnwrapAnnotatedValue ? require_internal_annotations.unwrapInjectedAnnotationWrapper(endResult.value) : endResult.value
218
- };
219
- }
220
- async function attemptParseAsync(parser, args, mode = "complete", session) {
221
- const shouldUnwrapAnnotatedValue = require_internal_annotations.isInjectedAnnotationWrapper(parser.initialState);
222
- const exec = createParseExec(parser);
223
- let context = require_internal_parser.createParserContext({
224
- buffer: args,
225
- state: parser.initialState,
226
- optionsTerminated: false
227
- }, exec);
228
- do {
229
- const result = await parser.parse(context);
230
- if (!result.success) {
231
- const progress = getFailureProgress(args, context.buffer, result.consumed);
232
- return {
233
- kind: "failure",
234
- error: result.error,
235
- remainingArgs: progress.remainingArgs,
236
- consumedCount: progress.consumedCount,
237
- optionsTerminated: context.optionsTerminated,
238
- commandPath: getCommandPath(context.exec)
239
- };
240
- }
241
- const previousBuffer = context.buffer;
242
- context = result.next;
243
- if (isBufferUnchanged(previousBuffer, context.buffer)) {
244
- const progress = getFailureProgress(args, previousBuffer, result.consumed.length);
245
- return {
246
- kind: "failure",
247
- error: require_message.message`Unexpected option or argument: ${context.buffer[0]}.`,
248
- remainingArgs: progress.remainingArgs,
249
- consumedCount: progress.consumedCount,
250
- optionsTerminated: context.optionsTerminated,
251
- commandPath: getCommandPath(context.exec)
252
- };
253
- }
254
- } while (context.buffer.length > 0);
255
- if (mode === "parse-only") return {
256
- kind: "success",
257
- value: void 0
258
- };
259
- const endResult = await parser.complete(context.state, createCompleteExec(exec, context, session));
260
- if (!endResult.success) return {
261
- kind: "failure",
262
- error: endResult.error,
263
- remainingArgs: [],
264
- consumedCount: args.length,
265
- optionsTerminated: context.optionsTerminated,
266
- commandPath: getCommandPath(context.exec)
267
- };
268
- return {
269
- kind: "success",
270
- value: shouldUnwrapAnnotatedValue ? require_internal_annotations.unwrapInjectedAnnotationWrapper(endResult.value) : endResult.value
271
- };
272
- }
273
137
  function createPhase2SeedExec(parser, context, session) {
274
138
  const exec = {
275
139
  usage: parser.usage,
@@ -284,7 +148,7 @@ function createPhase2SeedExec(parser, context, session) {
284
148
  phase: "complete",
285
149
  dependencyRuntime: runtime,
286
150
  dependencyRegistry: runtime.registry,
287
- commandPath: getCommandPath(context.exec),
151
+ commandPath: context.exec?.commandPath ?? [],
288
152
  trace: context.exec?.trace ?? context.trace ?? exec.trace,
289
153
  effectfulCompletionSession: session ?? require_internal_parser.createEffectfulCompletionSession()
290
154
  };
@@ -1284,19 +1148,25 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1284
1148
  };
1285
1149
  const parserMode = parser.mode;
1286
1150
  return require_mode_dispatch.dispatchByMode(parserMode, () => {
1287
- const attempted = attemptParseSync(parser, args, "complete", getEffectfulSessionOption(options));
1151
+ const attempted = require_internal_parser.attemptParseSync(parser, args, {
1152
+ mode: "complete",
1153
+ session: getEffectfulSessionOption(options)
1154
+ });
1288
1155
  const classified = attempted.kind === "success" ? {
1289
1156
  type: "success",
1290
- value: attempted.value
1157
+ value: attempted.result.value
1291
1158
  } : classifyParseFailure(attempted, helpOptionConfig ? [...helpOptionNames] : [], helpCommandConfig ? [...helpCommandNames] : [], versionOptionConfig ? [...versionOptionNames] : [], versionCommandConfig ? [...versionCommandNames] : [], completionOptionConfig ? [...completionOptionNames] : [], completionCommandConfig ? [...completionCommandNames] : []);
1292
1159
  const handled = handleResult(classified);
1293
1160
  if (handled instanceof Promise) throw new RunParserError("Synchronous parser returned async result.");
1294
1161
  return handled;
1295
1162
  }, async () => {
1296
- const attempted = await attemptParseAsync(parser, args, "complete", getEffectfulSessionOption(options));
1163
+ const attempted = await require_internal_parser.attemptParseAsync(parser, args, {
1164
+ mode: "complete",
1165
+ session: getEffectfulSessionOption(options)
1166
+ });
1297
1167
  const classified = attempted.kind === "success" ? {
1298
1168
  type: "success",
1299
- value: attempted.value
1169
+ value: attempted.result.value
1300
1170
  } : classifyParseFailure(attempted, helpOptionConfig ? [...helpOptionNames] : [], helpCommandConfig ? [...helpCommandNames] : [], versionOptionConfig ? [...versionOptionNames] : [], versionCommandConfig ? [...versionCommandNames] : [], completionOptionConfig ? [...completionOptionNames] : [], completionCommandConfig ? [...completionCommandNames] : []);
1301
1171
  const handled = handleResult(classified);
1302
1172
  return handled instanceof Promise ? await handled : handled;
@@ -1423,7 +1293,7 @@ function shouldProbeEarlyExit(options, needsTwoPhase) {
1423
1293
  * handled without collecting source-context annotations first.
1424
1294
  */
1425
1295
  function needsEarlyExitSync(parser, args, options) {
1426
- const attempted = attemptParseSync(parser, args, "parse-only");
1296
+ const attempted = require_internal_parser.attemptParseSync(parser, args, { mode: "parse-only" });
1427
1297
  if (attempted.kind === "success") return false;
1428
1298
  return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
1429
1299
  }
@@ -1431,7 +1301,7 @@ function needsEarlyExitSync(parser, args, options) {
1431
1301
  * Async variant of {@link needsEarlyExitSync}.
1432
1302
  */
1433
1303
  async function needsEarlyExitAsync(parser, args, options) {
1434
- const attempted = await attemptParseAsync(parser, args, "parse-only");
1304
+ const attempted = await require_internal_parser.attemptParseAsync(parser, args, { mode: "parse-only" });
1435
1305
  if (attempted.kind === "success") return false;
1436
1306
  return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
1437
1307
  }
package/dist/facade.js CHANGED
@@ -1,4 +1,4 @@
1
- import { injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./internal/annotations.js";
1
+ import { injectAnnotations } from "./internal/annotations.js";
2
2
  import { commandLine, formatMessage, lineBreak, message, optionName, text, value } from "./message.js";
3
3
  import { validateCommandNames, validateContextIds, validateMetaNameCollisions, validateOptionNames, validateProgramName } from "./validate.js";
4
4
  import { cloneUsage, formatUsage, isSuggestionHidden, normalizeUsage } from "./usage.js";
@@ -6,7 +6,7 @@ import { formatDocPage } from "./doc.js";
6
6
  import { dispatchByMode } from "./internal/mode-dispatch.js";
7
7
  import { collectExplicitSourceValues, collectExplicitSourceValuesAsync, createDependencyRuntimeContext } from "./dependency-runtime.js";
8
8
  import { createInputTrace } from "./input-trace.js";
9
- import { createEffectfulCompletionSession, createParserContext, getDocPage } from "./internal/parser.js";
9
+ import { attemptParseAsync, attemptParseSync, createEffectfulCompletionSession, createParserContext, getDocPage } from "./internal/parser.js";
10
10
  import { bash, fish, nu, pwsh, zsh } from "./completion.js";
11
11
  import { allowDuplicateLeadingCommandNamesKey, hiddenCommandAliasesKey } from "./internal/command-alias.js";
12
12
  import { completeOrExtractPhase2Seed } from "./phase2-seed.js";
@@ -98,24 +98,6 @@ function prepareParsedForContexts(parsed, deferred, deferredKeys) {
98
98
  function isBufferUnchanged(previous, current) {
99
99
  return current.length > 0 && current.length === previous.length && current.every((item, i) => item === previous[i]);
100
100
  }
101
- function getFailureProgress(args, buffer, consumedInStep) {
102
- return {
103
- remainingArgs: buffer.slice(consumedInStep),
104
- consumedCount: args.length - buffer.length + consumedInStep
105
- };
106
- }
107
- function createParseExec(parser) {
108
- return {
109
- usage: parser.usage,
110
- phase: "parse",
111
- path: [],
112
- commandPath: [],
113
- trace: createInputTrace()
114
- };
115
- }
116
- function getCommandPath(exec) {
117
- return exec?.commandPath ?? [];
118
- }
119
101
  const effectfulSessionOptionsKey = Symbol("@optique/core/facade/effectfulSessionOptionsKey");
120
102
  function getEffectfulSessionOption(options) {
121
103
  return options[effectfulSessionOptionsKey];
@@ -152,124 +134,6 @@ function createRunWithSessions() {
152
134
  finalSession
153
135
  };
154
136
  }
155
- function createCompleteExec(exec, context, session) {
156
- const runtime = createDependencyRuntimeContext();
157
- return {
158
- ...exec,
159
- phase: "complete",
160
- dependencyRuntime: runtime,
161
- dependencyRegistry: runtime.registry,
162
- commandPath: getCommandPath(context.exec) ?? exec.commandPath,
163
- trace: context.exec?.trace ?? context.trace ?? exec.trace,
164
- effectfulCompletionSession: session ?? createEffectfulCompletionSession()
165
- };
166
- }
167
- function attemptParseSync(parser, args, mode = "complete", session) {
168
- const shouldUnwrapAnnotatedValue = isInjectedAnnotationWrapper(parser.initialState);
169
- const exec = createParseExec(parser);
170
- let context = createParserContext({
171
- buffer: args,
172
- state: parser.initialState,
173
- optionsTerminated: false
174
- }, exec);
175
- do {
176
- const result = parser.parse(context);
177
- if (!result.success) {
178
- const progress = getFailureProgress(args, context.buffer, result.consumed);
179
- return {
180
- kind: "failure",
181
- error: result.error,
182
- remainingArgs: progress.remainingArgs,
183
- consumedCount: progress.consumedCount,
184
- optionsTerminated: context.optionsTerminated,
185
- commandPath: getCommandPath(context.exec)
186
- };
187
- }
188
- const previousBuffer = context.buffer;
189
- context = result.next;
190
- if (isBufferUnchanged(previousBuffer, context.buffer)) {
191
- const progress = getFailureProgress(args, previousBuffer, result.consumed.length);
192
- return {
193
- kind: "failure",
194
- error: message`Unexpected option or argument: ${context.buffer[0]}.`,
195
- remainingArgs: progress.remainingArgs,
196
- consumedCount: progress.consumedCount,
197
- optionsTerminated: context.optionsTerminated,
198
- commandPath: getCommandPath(context.exec)
199
- };
200
- }
201
- } while (context.buffer.length > 0);
202
- if (mode === "parse-only") return {
203
- kind: "success",
204
- value: void 0
205
- };
206
- const endResult = parser.complete(context.state, createCompleteExec(exec, context, session));
207
- if (!endResult.success) return {
208
- kind: "failure",
209
- error: endResult.error,
210
- remainingArgs: [],
211
- consumedCount: args.length,
212
- optionsTerminated: context.optionsTerminated,
213
- commandPath: getCommandPath(context.exec)
214
- };
215
- return {
216
- kind: "success",
217
- value: shouldUnwrapAnnotatedValue ? unwrapInjectedAnnotationWrapper(endResult.value) : endResult.value
218
- };
219
- }
220
- async function attemptParseAsync(parser, args, mode = "complete", session) {
221
- const shouldUnwrapAnnotatedValue = isInjectedAnnotationWrapper(parser.initialState);
222
- const exec = createParseExec(parser);
223
- let context = createParserContext({
224
- buffer: args,
225
- state: parser.initialState,
226
- optionsTerminated: false
227
- }, exec);
228
- do {
229
- const result = await parser.parse(context);
230
- if (!result.success) {
231
- const progress = getFailureProgress(args, context.buffer, result.consumed);
232
- return {
233
- kind: "failure",
234
- error: result.error,
235
- remainingArgs: progress.remainingArgs,
236
- consumedCount: progress.consumedCount,
237
- optionsTerminated: context.optionsTerminated,
238
- commandPath: getCommandPath(context.exec)
239
- };
240
- }
241
- const previousBuffer = context.buffer;
242
- context = result.next;
243
- if (isBufferUnchanged(previousBuffer, context.buffer)) {
244
- const progress = getFailureProgress(args, previousBuffer, result.consumed.length);
245
- return {
246
- kind: "failure",
247
- error: message`Unexpected option or argument: ${context.buffer[0]}.`,
248
- remainingArgs: progress.remainingArgs,
249
- consumedCount: progress.consumedCount,
250
- optionsTerminated: context.optionsTerminated,
251
- commandPath: getCommandPath(context.exec)
252
- };
253
- }
254
- } while (context.buffer.length > 0);
255
- if (mode === "parse-only") return {
256
- kind: "success",
257
- value: void 0
258
- };
259
- const endResult = await parser.complete(context.state, createCompleteExec(exec, context, session));
260
- if (!endResult.success) return {
261
- kind: "failure",
262
- error: endResult.error,
263
- remainingArgs: [],
264
- consumedCount: args.length,
265
- optionsTerminated: context.optionsTerminated,
266
- commandPath: getCommandPath(context.exec)
267
- };
268
- return {
269
- kind: "success",
270
- value: shouldUnwrapAnnotatedValue ? unwrapInjectedAnnotationWrapper(endResult.value) : endResult.value
271
- };
272
- }
273
137
  function createPhase2SeedExec(parser, context, session) {
274
138
  const exec = {
275
139
  usage: parser.usage,
@@ -284,7 +148,7 @@ function createPhase2SeedExec(parser, context, session) {
284
148
  phase: "complete",
285
149
  dependencyRuntime: runtime,
286
150
  dependencyRegistry: runtime.registry,
287
- commandPath: getCommandPath(context.exec),
151
+ commandPath: context.exec?.commandPath ?? [],
288
152
  trace: context.exec?.trace ?? context.trace ?? exec.trace,
289
153
  effectfulCompletionSession: session ?? createEffectfulCompletionSession()
290
154
  };
@@ -1284,19 +1148,25 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1284
1148
  };
1285
1149
  const parserMode = parser.mode;
1286
1150
  return dispatchByMode(parserMode, () => {
1287
- const attempted = attemptParseSync(parser, args, "complete", getEffectfulSessionOption(options));
1151
+ const attempted = attemptParseSync(parser, args, {
1152
+ mode: "complete",
1153
+ session: getEffectfulSessionOption(options)
1154
+ });
1288
1155
  const classified = attempted.kind === "success" ? {
1289
1156
  type: "success",
1290
- value: attempted.value
1157
+ value: attempted.result.value
1291
1158
  } : classifyParseFailure(attempted, helpOptionConfig ? [...helpOptionNames] : [], helpCommandConfig ? [...helpCommandNames] : [], versionOptionConfig ? [...versionOptionNames] : [], versionCommandConfig ? [...versionCommandNames] : [], completionOptionConfig ? [...completionOptionNames] : [], completionCommandConfig ? [...completionCommandNames] : []);
1292
1159
  const handled = handleResult(classified);
1293
1160
  if (handled instanceof Promise) throw new RunParserError("Synchronous parser returned async result.");
1294
1161
  return handled;
1295
1162
  }, async () => {
1296
- const attempted = await attemptParseAsync(parser, args, "complete", getEffectfulSessionOption(options));
1163
+ const attempted = await attemptParseAsync(parser, args, {
1164
+ mode: "complete",
1165
+ session: getEffectfulSessionOption(options)
1166
+ });
1297
1167
  const classified = attempted.kind === "success" ? {
1298
1168
  type: "success",
1299
- value: attempted.value
1169
+ value: attempted.result.value
1300
1170
  } : classifyParseFailure(attempted, helpOptionConfig ? [...helpOptionNames] : [], helpCommandConfig ? [...helpCommandNames] : [], versionOptionConfig ? [...versionOptionNames] : [], versionCommandConfig ? [...versionCommandNames] : [], completionOptionConfig ? [...completionOptionNames] : [], completionCommandConfig ? [...completionCommandNames] : []);
1301
1171
  const handled = handleResult(classified);
1302
1172
  return handled instanceof Promise ? await handled : handled;
@@ -1423,7 +1293,7 @@ function shouldProbeEarlyExit(options, needsTwoPhase) {
1423
1293
  * handled without collecting source-context annotations first.
1424
1294
  */
1425
1295
  function needsEarlyExitSync(parser, args, options) {
1426
- const attempted = attemptParseSync(parser, args, "parse-only");
1296
+ const attempted = attemptParseSync(parser, args, { mode: "parse-only" });
1427
1297
  if (attempted.kind === "success") return false;
1428
1298
  return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
1429
1299
  }
@@ -1431,7 +1301,7 @@ function needsEarlyExitSync(parser, args, options) {
1431
1301
  * Async variant of {@link needsEarlyExitSync}.
1432
1302
  */
1433
1303
  async function needsEarlyExitAsync(parser, args, options) {
1434
- const attempted = await attemptParseAsync(parser, args, "parse-only");
1304
+ const attempted = await attemptParseAsync(parser, args, { mode: "parse-only" });
1435
1305
  if (attempted.kind === "success") return false;
1436
1306
  return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
1437
1307
  }
package/dist/index.cjs CHANGED
@@ -104,6 +104,7 @@ exports.optional = require_modifiers.optional;
104
104
  exports.or = require_constructs.or;
105
105
  exports.parse = require_internal_parser.parse;
106
106
  exports.parseAsync = require_internal_parser.parseAsync;
107
+ exports.parseDetailed = require_internal_parser.parseDetailed;
107
108
  exports.parseSync = require_internal_parser.parseSync;
108
109
  exports.passThrough = require_primitives.passThrough;
109
110
  exports.port = require_valueparser.port;
package/dist/index.d.cts CHANGED
@@ -4,7 +4,7 @@ import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLin
4
4
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
5
5
  import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.cjs";
6
6
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
7
- import { CombineModes, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.cjs";
7
+ import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.cjs";
8
8
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
9
9
  import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser, MultipleErrorOptions, MultipleOptions, ParserModifiers, WithDefaultError, WithDefaultOptions, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
10
10
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, SeqOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.cjs";
@@ -12,4 +12,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
12
12
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
13
13
  import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
14
14
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
15
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
15
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLin
4
4
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
5
5
  import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
6
6
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
7
- import { CombineModes, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
7
+ import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
8
8
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
9
9
  import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser, MultipleErrorOptions, MultipleOptions, ParserModifiers, WithDefaultError, WithDefaultOptions, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
10
10
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, SeqOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.js";
@@ -12,4 +12,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
12
12
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
13
13
  import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
14
14
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
15
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
15
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { commandLine, envVar, formatMessage, lineBreak, link, message, metavar,
3
3
  import { cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
4
4
  import { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
5
5
  import { dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
6
- import { createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
6
+ import { createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
7
7
  import { bash, fish, nu, pwsh, zsh } from "./completion.js";
8
8
  import { WithDefaultError, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
9
9
  import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.js";
@@ -12,4 +12,4 @@ import { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron,
12
12
  import { argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
13
13
  import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
14
14
 
15
- export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
15
+ export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
@@ -17,6 +17,24 @@ function dispatchByMode(mode, syncFn, asyncFn) {
17
17
  if (mode === "async") return asyncFn();
18
18
  return syncFn();
19
19
  }
20
+ /**
21
+ * Dispatches a parser to a callback narrowed to its runtime mode.
22
+ *
23
+ * TypeScript cannot narrow the generic mode parameter of a {@link Parser}
24
+ * from its `mode` property. This helper keeps the necessary parser assertions
25
+ * at the mode-dispatch boundary while giving each callback a precise parser
26
+ * type.
27
+ *
28
+ * @param parser The parser whose mode selects the callback.
29
+ * @param syncFn Function to call with a synchronous parser.
30
+ * @param asyncFn Function to call with an asynchronous parser.
31
+ * @returns The callback result with the parser's mode wrapping.
32
+ * @internal
33
+ * @since 1.3.0
34
+ */
35
+ function dispatchParserByMode(parser, syncFn, asyncFn) {
36
+ return dispatchByMode(parser.mode, () => syncFn(parser), () => asyncFn(parser));
37
+ }
20
38
  function wrapForMode(mode, value) {
21
39
  if (mode === "async") return Promise.resolve(value);
22
40
  if (value instanceof Promise) throw new TypeError("Synchronous mode cannot wrap Promise value.");
@@ -92,6 +110,7 @@ function dispatchIterableByMode(mode, syncFn, asyncFn) {
92
110
  //#endregion
93
111
  exports.dispatchByMode = dispatchByMode;
94
112
  exports.dispatchIterableByMode = dispatchIterableByMode;
113
+ exports.dispatchParserByMode = dispatchParserByMode;
95
114
  exports.mapMaybePromiseByMode = mapMaybePromiseByMode;
96
115
  exports.mapModeValue = mapModeValue;
97
116
  exports.wrapForMode = wrapForMode;
@@ -16,6 +16,22 @@ import { Mode, ModeValue } from "./parser.cjs";
16
16
  * @since 0.10.0
17
17
  */
18
18
  declare function dispatchByMode<M extends Mode, T>(mode: M, syncFn: () => T, asyncFn: () => Promise<T>): ModeValue<M, T>;
19
+ /**
20
+ * Dispatches a parser to a callback narrowed to its runtime mode.
21
+ *
22
+ * TypeScript cannot narrow the generic mode parameter of a {@link Parser}
23
+ * from its `mode` property. This helper keeps the necessary parser assertions
24
+ * at the mode-dispatch boundary while giving each callback a precise parser
25
+ * type.
26
+ *
27
+ * @param parser The parser whose mode selects the callback.
28
+ * @param syncFn Function to call with a synchronous parser.
29
+ * @param asyncFn Function to call with an asynchronous parser.
30
+ * @returns The callback result with the parser's mode wrapping.
31
+ * @internal
32
+ * @since 1.3.0
33
+ */
34
+
19
35
  /**
20
36
  * Wraps a value so it matches the parser execution mode.
21
37
  *
@@ -16,6 +16,22 @@ import { Mode, ModeValue } from "./parser.js";
16
16
  * @since 0.10.0
17
17
  */
18
18
  declare function dispatchByMode<M extends Mode, T>(mode: M, syncFn: () => T, asyncFn: () => Promise<T>): ModeValue<M, T>;
19
+ /**
20
+ * Dispatches a parser to a callback narrowed to its runtime mode.
21
+ *
22
+ * TypeScript cannot narrow the generic mode parameter of a {@link Parser}
23
+ * from its `mode` property. This helper keeps the necessary parser assertions
24
+ * at the mode-dispatch boundary while giving each callback a precise parser
25
+ * type.
26
+ *
27
+ * @param parser The parser whose mode selects the callback.
28
+ * @param syncFn Function to call with a synchronous parser.
29
+ * @param asyncFn Function to call with an asynchronous parser.
30
+ * @returns The callback result with the parser's mode wrapping.
31
+ * @internal
32
+ * @since 1.3.0
33
+ */
34
+
19
35
  /**
20
36
  * Wraps a value so it matches the parser execution mode.
21
37
  *
@@ -16,6 +16,24 @@ function dispatchByMode(mode, syncFn, asyncFn) {
16
16
  if (mode === "async") return asyncFn();
17
17
  return syncFn();
18
18
  }
19
+ /**
20
+ * Dispatches a parser to a callback narrowed to its runtime mode.
21
+ *
22
+ * TypeScript cannot narrow the generic mode parameter of a {@link Parser}
23
+ * from its `mode` property. This helper keeps the necessary parser assertions
24
+ * at the mode-dispatch boundary while giving each callback a precise parser
25
+ * type.
26
+ *
27
+ * @param parser The parser whose mode selects the callback.
28
+ * @param syncFn Function to call with a synchronous parser.
29
+ * @param asyncFn Function to call with an asynchronous parser.
30
+ * @returns The callback result with the parser's mode wrapping.
31
+ * @internal
32
+ * @since 1.3.0
33
+ */
34
+ function dispatchParserByMode(parser, syncFn, asyncFn) {
35
+ return dispatchByMode(parser.mode, () => syncFn(parser), () => asyncFn(parser));
36
+ }
19
37
  function wrapForMode(mode, value) {
20
38
  if (mode === "async") return Promise.resolve(value);
21
39
  if (value instanceof Promise) throw new TypeError("Synchronous mode cannot wrap Promise value.");
@@ -89,4 +107,4 @@ function dispatchIterableByMode(mode, syncFn, asyncFn) {
89
107
  }
90
108
 
91
109
  //#endregion
92
- export { dispatchByMode, dispatchIterableByMode, mapMaybePromiseByMode, mapModeValue, wrapForMode, wrapIterableForMode };
110
+ export { dispatchByMode, dispatchIterableByMode, dispatchParserByMode, mapMaybePromiseByMode, mapModeValue, wrapForMode, wrapIterableForMode };