@optique/core 1.0.0-dev.1734 → 1.0.0-dev.1737
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/constructs.cjs +2 -3
- package/dist/constructs.js +2 -3
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/modifiers.cjs +58 -23
- package/dist/modifiers.d.cts +1 -10
- package/dist/modifiers.d.ts +1 -10
- package/dist/modifiers.js +61 -25
- package/dist/parser.cjs +0 -1
- package/dist/parser.d.cts +2 -2
- package/dist/parser.d.ts +2 -2
- package/dist/parser.js +2 -2
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require_validate = require('./validate.cjs');
|
|
|
5
5
|
const require_usage = require('./usage.cjs');
|
|
6
6
|
const require_doc = require('./doc.cjs');
|
|
7
7
|
const require_mode_dispatch = require('./mode-dispatch.cjs');
|
|
8
|
-
const require_modifiers = require('./modifiers.cjs');
|
|
9
8
|
const require_suggestion = require('./suggestion.cjs');
|
|
10
9
|
const require_usage_internals = require('./usage-internals.cjs');
|
|
11
10
|
const require_parser = require('./parser.cjs');
|
|
@@ -1765,7 +1764,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1765
1764
|
for (const [field, parser] of parserPairs) {
|
|
1766
1765
|
if (consumedFields.has(field)) continue;
|
|
1767
1766
|
const typedParser = parser;
|
|
1768
|
-
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken
|
|
1767
|
+
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken) continue;
|
|
1769
1768
|
const fieldState = getFieldState(field, parser);
|
|
1770
1769
|
const result = typedParser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1771
1770
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
@@ -1862,7 +1861,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1862
1861
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
1863
1862
|
for (const [field, parser] of parserPairs) {
|
|
1864
1863
|
if (consumedFields.has(field)) continue;
|
|
1865
|
-
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken
|
|
1864
|
+
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
1866
1865
|
const fieldState = getFieldState(field, parser);
|
|
1867
1866
|
const resultOrPromise = parser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1868
1867
|
const result = await resultOrPromise;
|
package/dist/constructs.js
CHANGED
|
@@ -5,7 +5,6 @@ import { validateLabel } from "./validate.js";
|
|
|
5
5
|
import { extractArgumentMetavars, extractCommandNames, extractOptionNames, isDocHidden, mergeHidden } from "./usage.js";
|
|
6
6
|
import { deduplicateDocFragments } from "./doc.js";
|
|
7
7
|
import { dispatchByMode, dispatchIterableByMode } from "./mode-dispatch.js";
|
|
8
|
-
import { optionalStyleWrapperKey } from "./modifiers.js";
|
|
9
8
|
import { DEFAULT_FIND_SIMILAR_OPTIONS, createErrorWithSuggestions, createSuggestionMessage, deduplicateSuggestions, findSimilar } from "./suggestion.js";
|
|
10
9
|
import { collectLeadingCandidates } from "./usage-internals.js";
|
|
11
10
|
import { defineInheritedAnnotationParser, getParserSuggestRuntimeNodes, inheritParentAnnotationsKey, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
|
|
@@ -1765,7 +1764,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1765
1764
|
for (const [field, parser] of parserPairs) {
|
|
1766
1765
|
if (consumedFields.has(field)) continue;
|
|
1767
1766
|
const typedParser = parser;
|
|
1768
|
-
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken
|
|
1767
|
+
if (parser.leadingNames.size > 0 || typedParser.acceptingAnyToken) continue;
|
|
1769
1768
|
const fieldState = getFieldState(field, parser);
|
|
1770
1769
|
const result = typedParser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1771
1770
|
if (result.success && result.consumed.length === 0 && result.next.state !== fieldState) {
|
|
@@ -1862,7 +1861,7 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
1862
1861
|
const getFieldState = createFieldStateGetter(currentContext.state, getObjectParseChildState);
|
|
1863
1862
|
for (const [field, parser] of parserPairs) {
|
|
1864
1863
|
if (consumedFields.has(field)) continue;
|
|
1865
|
-
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken
|
|
1864
|
+
if (parser.leadingNames.size > 0 || parser.acceptingAnyToken) continue;
|
|
1866
1865
|
const fieldState = getFieldState(field, parser);
|
|
1867
1866
|
const resultOrPromise = parser.parse(withChildContext(currentContext, field, fieldState, parser));
|
|
1868
1867
|
const result = await resultOrPromise;
|
package/dist/index.cjs
CHANGED
|
@@ -117,7 +117,6 @@ exports.option = require_primitives.option;
|
|
|
117
117
|
exports.optionName = require_message.optionName;
|
|
118
118
|
exports.optionNames = require_message.optionNames;
|
|
119
119
|
exports.optional = require_modifiers.optional;
|
|
120
|
-
exports.optionalStyleWrapperKey = require_modifiers.optionalStyleWrapperKey;
|
|
121
120
|
exports.or = require_constructs.or;
|
|
122
121
|
exports.parse = require_parser.parse;
|
|
123
122
|
exports.parseAsync = require_parser.parseAsync;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,11 +5,11 @@ import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, Usa
|
|
|
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, DeferredMap, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, checkEnumOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.cjs";
|
|
7
7
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.cjs";
|
|
8
|
-
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional,
|
|
8
|
+
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
|
|
9
9
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.cjs";
|
|
10
10
|
import { CombineModes, DocState, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, annotationWrapperRequiresSourceBindingKey, composeWrappedSourceMetadata, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, inheritParentAnnotationsKey, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync, unmatchedNonCliDependencySourceStateMarker } from "./parser.cjs";
|
|
11
11
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
|
|
12
12
|
import { ParserValuePlaceholder, SourceContext } from "./context.cjs";
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDependencyValues, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.cjs";
|
|
14
14
|
import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional,
|
|
15
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, Usa
|
|
|
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, DeferredMap, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, checkEnumOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
|
|
7
7
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
8
|
-
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional,
|
|
8
|
+
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
9
9
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
10
10
|
import { CombineModes, DocState, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, annotationWrapperRequiresSourceBindingKey, composeWrappedSourceMetadata, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, inheritParentAnnotationsKey, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
|
|
11
11
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
12
12
|
import { ParserValuePlaceholder, SourceContext } from "./context.js";
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDependencyValues, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
|
|
14
14
|
import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional,
|
|
15
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredMap, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
|
4
4
|
import { DependencyRegistry, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, getSnapshottedDefaultDependencyValues, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, singleDefaultValue, snapshotDefaultDependencyValues, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
|
|
5
5
|
import { cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
6
6
|
import { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
|
|
7
|
-
import { WithDefaultError, map, multiple, nonEmpty, optional,
|
|
7
|
+
import { WithDefaultError, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
8
8
|
import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
9
9
|
import { checkBooleanOption, checkEnumOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
|
|
10
10
|
import { argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
@@ -12,4 +12,4 @@ import { annotationWrapperRequiresSourceBindingKey, composeWrappedSourceMetadata
|
|
|
12
12
|
import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
13
13
|
import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
14
|
|
|
15
|
-
export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional,
|
|
15
|
+
export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, annotationWrapperRequiresSourceBindingKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, composeWrappedSourceMetadata, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createParserContext, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultDependencyValueSnapshot, defaultValues, deferredParseMarker, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDelegatingSuggestRuntimeNodes, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, getSnapshottedDefaultDependencyValues, group, hostname, inheritParentAnnotationsKey, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, singleDefaultValue, snapshotDefaultDependencyValues, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, unmatchedNonCliDependencySourceStateMarker, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/modifiers.cjs
CHANGED
|
@@ -5,15 +5,6 @@ const require_dependency_metadata = require('./dependency-metadata.cjs');
|
|
|
5
5
|
const require_parser = require('./parser.cjs');
|
|
6
6
|
|
|
7
7
|
//#region src/modifiers.ts
|
|
8
|
-
/**
|
|
9
|
-
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
10
|
-
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
11
|
-
* `prompt()`, since these wrappers have their own completion semantics
|
|
12
|
-
* that should not be short-circuited during parse.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
const optionalStyleWrapperKey = Symbol.for("@optique/core/optionalStyleWrapper");
|
|
17
8
|
function withChildExecPath(exec, segment) {
|
|
18
9
|
if (exec == null) return void 0;
|
|
19
10
|
return {
|
|
@@ -89,6 +80,28 @@ function isPromiseLike(value) {
|
|
|
89
80
|
return value != null && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
90
81
|
}
|
|
91
82
|
/**
|
|
83
|
+
* Computes the inner state to pass through to the wrapped parser inside
|
|
84
|
+
* {@link optional} / {@link withDefault}. When the outer state is an
|
|
85
|
+
* array, the inner state is `state[0]`. Otherwise — including the
|
|
86
|
+
* common case where `optional()` sits at top level and the outer state
|
|
87
|
+
* is either `undefined` or an annotation wrapper from `parseOptionalLike`
|
|
88
|
+
* / `parse({ annotations })` — we use the wrapped parser's
|
|
89
|
+
* `initialState`, propagating annotations from the outer state so that
|
|
90
|
+
* source-binding wrappers under `optional()` / `withDefault()` (e.g.,
|
|
91
|
+
* `bindEnv()` / `bindConfig()`) can resolve their fallbacks.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
function deriveOptionalInnerParseState(outerState, parser) {
|
|
96
|
+
if (Array.isArray(outerState)) return outerState[0];
|
|
97
|
+
const initial = parser.initialState;
|
|
98
|
+
if (outerState != null && typeof outerState === "object") {
|
|
99
|
+
const annotations = require_annotations.getAnnotations(outerState);
|
|
100
|
+
if (annotations != null) return require_annotations.injectAnnotations(initial, annotations);
|
|
101
|
+
}
|
|
102
|
+
return initial;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
92
105
|
* Internal helper for optional-style parsing logic shared by optional()
|
|
93
106
|
* and withDefault(). Handles the common pattern of:
|
|
94
107
|
* - Unwrapping optional state to inner parser state
|
|
@@ -97,7 +110,7 @@ function isPromiseLike(value) {
|
|
|
97
110
|
* @internal
|
|
98
111
|
*/
|
|
99
112
|
function parseOptionalStyleSync(context, parser) {
|
|
100
|
-
const innerState =
|
|
113
|
+
const innerState = deriveOptionalInnerParseState(context.state, parser);
|
|
101
114
|
const result = parser.parse({
|
|
102
115
|
...context,
|
|
103
116
|
state: innerState
|
|
@@ -109,7 +122,7 @@ function parseOptionalStyleSync(context, parser) {
|
|
|
109
122
|
* @internal
|
|
110
123
|
*/
|
|
111
124
|
async function parseOptionalStyleAsync(context, parser) {
|
|
112
|
-
const innerState =
|
|
125
|
+
const innerState = deriveOptionalInnerParseState(context.state, parser);
|
|
113
126
|
const result = await parser.parse({
|
|
114
127
|
...context,
|
|
115
128
|
state: innerState
|
|
@@ -213,7 +226,7 @@ function optional(parser) {
|
|
|
213
226
|
$mode: parser.$mode,
|
|
214
227
|
$valueType: [],
|
|
215
228
|
$stateType: [],
|
|
216
|
-
[
|
|
229
|
+
...parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true ? { [require_parser.unmatchedNonCliDependencySourceStateMarker]: true } : {},
|
|
217
230
|
placeholder: void 0,
|
|
218
231
|
priority: parser.priority,
|
|
219
232
|
usage: [{
|
|
@@ -242,22 +255,26 @@ function optional(parser) {
|
|
|
242
255
|
},
|
|
243
256
|
complete(state, exec) {
|
|
244
257
|
if (!Array.isArray(state)) {
|
|
258
|
+
const delegateToInner = (resolvedInnerState) => {
|
|
259
|
+
const innerResult = require_mode_dispatch.dispatchByMode(parser.$mode, () => syncParser.complete(resolvedInnerState, exec), async () => await parser.complete(resolvedInnerState, exec));
|
|
260
|
+
return require_mode_dispatch.mapModeValue(parser.$mode, innerResult, (result) => result.success ? result : {
|
|
261
|
+
success: true,
|
|
262
|
+
value: void 0
|
|
263
|
+
});
|
|
264
|
+
};
|
|
245
265
|
if (typeof parser.shouldDeferCompletion === "function" && state != null && typeof state === "object") {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const innerResult = require_mode_dispatch.dispatchByMode(parser.$mode, () => syncParser.complete(innerState, exec), async () => await parser.complete(innerState, exec));
|
|
249
|
-
return require_mode_dispatch.mapModeValue(parser.$mode, innerResult, (result) => result.success ? result : {
|
|
250
|
-
success: true,
|
|
251
|
-
value: void 0
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
return innerComplete();
|
|
266
|
+
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
267
|
+
return delegateToInner(innerState);
|
|
255
268
|
}
|
|
256
269
|
const sourceMetadata = parser.dependencyMetadata?.source;
|
|
257
270
|
if (sourceMetadata?.preservesSourceValue !== false && sourceMetadata?.getMissingSourceValue != null) {
|
|
258
271
|
const delegatedState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
259
272
|
return require_mode_dispatch.dispatchByMode(parser.$mode, () => syncParser.complete(delegatedState, exec), async () => await parser.complete(delegatedState, exec));
|
|
260
273
|
}
|
|
274
|
+
if (parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object") {
|
|
275
|
+
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
276
|
+
return delegateToInner(innerState);
|
|
277
|
+
}
|
|
261
278
|
return {
|
|
262
279
|
success: true,
|
|
263
280
|
value: void 0
|
|
@@ -361,7 +378,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
361
378
|
$mode: parser.$mode,
|
|
362
379
|
$valueType: [],
|
|
363
380
|
$stateType: [],
|
|
364
|
-
[
|
|
381
|
+
...parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true ? { [require_parser.unmatchedNonCliDependencySourceStateMarker]: true } : {},
|
|
365
382
|
priority: parser.priority,
|
|
366
383
|
usage: [{
|
|
367
384
|
type: "optional",
|
|
@@ -401,6 +418,25 @@ function withDefault(parser, defaultValue, options) {
|
|
|
401
418
|
const innerResult = require_mode_dispatch.dispatchByMode(parser.$mode, () => syncParser.complete(innerState, exec), async () => await parser.complete(innerState, exec));
|
|
402
419
|
return innerResult;
|
|
403
420
|
}
|
|
421
|
+
if (parser[require_parser.unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object") {
|
|
422
|
+
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
423
|
+
const innerResult = require_mode_dispatch.dispatchByMode(parser.$mode, () => syncParser.complete(innerState, exec), async () => await parser.complete(innerState, exec));
|
|
424
|
+
const handleInnerResult = (result) => {
|
|
425
|
+
if (result.success && result.value !== void 0) return result;
|
|
426
|
+
try {
|
|
427
|
+
return {
|
|
428
|
+
success: true,
|
|
429
|
+
value: evaluateDefault()
|
|
430
|
+
};
|
|
431
|
+
} catch (error) {
|
|
432
|
+
return {
|
|
433
|
+
success: false,
|
|
434
|
+
error: error instanceof WithDefaultError ? error.errorMessage : require_message.message`${require_message.text(String(error))}`
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
return require_mode_dispatch.mapModeValue(parser.$mode, innerResult, handleInnerResult);
|
|
439
|
+
}
|
|
404
440
|
try {
|
|
405
441
|
const value = evaluateDefault();
|
|
406
442
|
return {
|
|
@@ -1221,5 +1257,4 @@ exports.map = map;
|
|
|
1221
1257
|
exports.multiple = multiple;
|
|
1222
1258
|
exports.nonEmpty = nonEmpty;
|
|
1223
1259
|
exports.optional = optional;
|
|
1224
|
-
exports.optionalStyleWrapperKey = optionalStyleWrapperKey;
|
|
1225
1260
|
exports.withDefault = withDefault;
|
package/dist/modifiers.d.cts
CHANGED
|
@@ -3,15 +3,6 @@ import { Mode, Parser } from "./parser.cjs";
|
|
|
3
3
|
|
|
4
4
|
//#region src/modifiers.d.ts
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
8
|
-
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
9
|
-
* `prompt()`, since these wrappers have their own completion semantics
|
|
10
|
-
* that should not be short-circuited during parse.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
declare const optionalStyleWrapperKey: unique symbol;
|
|
15
6
|
/**
|
|
16
7
|
* Creates a parser that makes another parser optional, allowing it to succeed
|
|
17
8
|
* without consuming input if the wrapped parser fails to match.
|
|
@@ -282,4 +273,4 @@ declare function multiple<M extends Mode, TValue, TState>(parser: Parser<M, TVal
|
|
|
282
273
|
*/
|
|
283
274
|
declare function nonEmpty<M extends Mode, T, TState>(parser: Parser<M, T, TState>): Parser<M, T, TState>;
|
|
284
275
|
//#endregion
|
|
285
|
-
export { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional,
|
|
276
|
+
export { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault };
|
package/dist/modifiers.d.ts
CHANGED
|
@@ -3,15 +3,6 @@ import { Mode, Parser } from "./parser.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/modifiers.d.ts
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
8
|
-
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
9
|
-
* `prompt()`, since these wrappers have their own completion semantics
|
|
10
|
-
* that should not be short-circuited during parse.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
declare const optionalStyleWrapperKey: unique symbol;
|
|
15
6
|
/**
|
|
16
7
|
* Creates a parser that makes another parser optional, allowing it to succeed
|
|
17
8
|
* without consuming input if the wrapped parser fails to match.
|
|
@@ -282,4 +273,4 @@ declare function multiple<M extends Mode, TValue, TState>(parser: Parser<M, TVal
|
|
|
282
273
|
*/
|
|
283
274
|
declare function nonEmpty<M extends Mode, T, TState>(parser: Parser<M, T, TState>): Parser<M, T, TState>;
|
|
284
275
|
//#endregion
|
|
285
|
-
export { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional,
|
|
276
|
+
export { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault };
|
package/dist/modifiers.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import { annotateFreshArray, annotationKey, getAnnotations, inheritAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
|
|
1
|
+
import { annotateFreshArray, annotationKey, getAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
|
|
2
2
|
import { formatMessage, message, text } from "./message.js";
|
|
3
3
|
import { dispatchByMode, dispatchIterableByMode, mapModeValue } from "./mode-dispatch.js";
|
|
4
4
|
import { composeDependencyMetadata } from "./dependency-metadata.js";
|
|
5
|
-
import { defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser } from "./parser.js";
|
|
5
|
+
import { defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, unmatchedNonCliDependencySourceStateMarker } from "./parser.js";
|
|
6
6
|
|
|
7
7
|
//#region src/modifiers.ts
|
|
8
|
-
/**
|
|
9
|
-
* Internal marker for wrappers that should be skipped by `object()`'s
|
|
10
|
-
* zero-consumption pass. Set on `optional()`, `withDefault()`, and
|
|
11
|
-
* `prompt()`, since these wrappers have their own completion semantics
|
|
12
|
-
* that should not be short-circuited during parse.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
const optionalStyleWrapperKey = Symbol.for("@optique/core/optionalStyleWrapper");
|
|
17
8
|
function withChildExecPath(exec, segment) {
|
|
18
9
|
if (exec == null) return void 0;
|
|
19
10
|
return {
|
|
@@ -89,6 +80,28 @@ function isPromiseLike(value) {
|
|
|
89
80
|
return value != null && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
90
81
|
}
|
|
91
82
|
/**
|
|
83
|
+
* Computes the inner state to pass through to the wrapped parser inside
|
|
84
|
+
* {@link optional} / {@link withDefault}. When the outer state is an
|
|
85
|
+
* array, the inner state is `state[0]`. Otherwise — including the
|
|
86
|
+
* common case where `optional()` sits at top level and the outer state
|
|
87
|
+
* is either `undefined` or an annotation wrapper from `parseOptionalLike`
|
|
88
|
+
* / `parse({ annotations })` — we use the wrapped parser's
|
|
89
|
+
* `initialState`, propagating annotations from the outer state so that
|
|
90
|
+
* source-binding wrappers under `optional()` / `withDefault()` (e.g.,
|
|
91
|
+
* `bindEnv()` / `bindConfig()`) can resolve their fallbacks.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
function deriveOptionalInnerParseState(outerState, parser) {
|
|
96
|
+
if (Array.isArray(outerState)) return outerState[0];
|
|
97
|
+
const initial = parser.initialState;
|
|
98
|
+
if (outerState != null && typeof outerState === "object") {
|
|
99
|
+
const annotations = getAnnotations(outerState);
|
|
100
|
+
if (annotations != null) return injectAnnotations(initial, annotations);
|
|
101
|
+
}
|
|
102
|
+
return initial;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
92
105
|
* Internal helper for optional-style parsing logic shared by optional()
|
|
93
106
|
* and withDefault(). Handles the common pattern of:
|
|
94
107
|
* - Unwrapping optional state to inner parser state
|
|
@@ -97,7 +110,7 @@ function isPromiseLike(value) {
|
|
|
97
110
|
* @internal
|
|
98
111
|
*/
|
|
99
112
|
function parseOptionalStyleSync(context, parser) {
|
|
100
|
-
const innerState =
|
|
113
|
+
const innerState = deriveOptionalInnerParseState(context.state, parser);
|
|
101
114
|
const result = parser.parse({
|
|
102
115
|
...context,
|
|
103
116
|
state: innerState
|
|
@@ -109,7 +122,7 @@ function parseOptionalStyleSync(context, parser) {
|
|
|
109
122
|
* @internal
|
|
110
123
|
*/
|
|
111
124
|
async function parseOptionalStyleAsync(context, parser) {
|
|
112
|
-
const innerState =
|
|
125
|
+
const innerState = deriveOptionalInnerParseState(context.state, parser);
|
|
113
126
|
const result = await parser.parse({
|
|
114
127
|
...context,
|
|
115
128
|
state: innerState
|
|
@@ -213,7 +226,7 @@ function optional(parser) {
|
|
|
213
226
|
$mode: parser.$mode,
|
|
214
227
|
$valueType: [],
|
|
215
228
|
$stateType: [],
|
|
216
|
-
[
|
|
229
|
+
...parser[unmatchedNonCliDependencySourceStateMarker] === true ? { [unmatchedNonCliDependencySourceStateMarker]: true } : {},
|
|
217
230
|
placeholder: void 0,
|
|
218
231
|
priority: parser.priority,
|
|
219
232
|
usage: [{
|
|
@@ -242,22 +255,26 @@ function optional(parser) {
|
|
|
242
255
|
},
|
|
243
256
|
complete(state, exec) {
|
|
244
257
|
if (!Array.isArray(state)) {
|
|
258
|
+
const delegateToInner = (resolvedInnerState) => {
|
|
259
|
+
const innerResult = dispatchByMode(parser.$mode, () => syncParser.complete(resolvedInnerState, exec), async () => await parser.complete(resolvedInnerState, exec));
|
|
260
|
+
return mapModeValue(parser.$mode, innerResult, (result) => result.success ? result : {
|
|
261
|
+
success: true,
|
|
262
|
+
value: void 0
|
|
263
|
+
});
|
|
264
|
+
};
|
|
245
265
|
if (typeof parser.shouldDeferCompletion === "function" && state != null && typeof state === "object") {
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const innerResult = dispatchByMode(parser.$mode, () => syncParser.complete(innerState, exec), async () => await parser.complete(innerState, exec));
|
|
249
|
-
return mapModeValue(parser.$mode, innerResult, (result) => result.success ? result : {
|
|
250
|
-
success: true,
|
|
251
|
-
value: void 0
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
return innerComplete();
|
|
266
|
+
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
267
|
+
return delegateToInner(innerState);
|
|
255
268
|
}
|
|
256
269
|
const sourceMetadata = parser.dependencyMetadata?.source;
|
|
257
270
|
if (sourceMetadata?.preservesSourceValue !== false && sourceMetadata?.getMissingSourceValue != null) {
|
|
258
271
|
const delegatedState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
259
272
|
return dispatchByMode(parser.$mode, () => syncParser.complete(delegatedState, exec), async () => await parser.complete(delegatedState, exec));
|
|
260
273
|
}
|
|
274
|
+
if (parser[unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object") {
|
|
275
|
+
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
276
|
+
return delegateToInner(innerState);
|
|
277
|
+
}
|
|
261
278
|
return {
|
|
262
279
|
success: true,
|
|
263
280
|
value: void 0
|
|
@@ -361,7 +378,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
361
378
|
$mode: parser.$mode,
|
|
362
379
|
$valueType: [],
|
|
363
380
|
$stateType: [],
|
|
364
|
-
[
|
|
381
|
+
...parser[unmatchedNonCliDependencySourceStateMarker] === true ? { [unmatchedNonCliDependencySourceStateMarker]: true } : {},
|
|
365
382
|
priority: parser.priority,
|
|
366
383
|
usage: [{
|
|
367
384
|
type: "optional",
|
|
@@ -401,6 +418,25 @@ function withDefault(parser, defaultValue, options) {
|
|
|
401
418
|
const innerResult = dispatchByMode(parser.$mode, () => syncParser.complete(innerState, exec), async () => await parser.complete(innerState, exec));
|
|
402
419
|
return innerResult;
|
|
403
420
|
}
|
|
421
|
+
if (parser[unmatchedNonCliDependencySourceStateMarker] === true && state != null && typeof state === "object") {
|
|
422
|
+
const innerState = normalizeOptionalLikeInnerState(state, parser.initialState, parser);
|
|
423
|
+
const innerResult = dispatchByMode(parser.$mode, () => syncParser.complete(innerState, exec), async () => await parser.complete(innerState, exec));
|
|
424
|
+
const handleInnerResult = (result) => {
|
|
425
|
+
if (result.success && result.value !== void 0) return result;
|
|
426
|
+
try {
|
|
427
|
+
return {
|
|
428
|
+
success: true,
|
|
429
|
+
value: evaluateDefault()
|
|
430
|
+
};
|
|
431
|
+
} catch (error) {
|
|
432
|
+
return {
|
|
433
|
+
success: false,
|
|
434
|
+
error: error instanceof WithDefaultError ? error.errorMessage : message`${text(String(error))}`
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
return mapModeValue(parser.$mode, innerResult, handleInnerResult);
|
|
439
|
+
}
|
|
404
440
|
try {
|
|
405
441
|
const value = evaluateDefault();
|
|
406
442
|
return {
|
|
@@ -1216,4 +1252,4 @@ function nonEmpty(parser) {
|
|
|
1216
1252
|
}
|
|
1217
1253
|
|
|
1218
1254
|
//#endregion
|
|
1219
|
-
export { WithDefaultError, map, multiple, nonEmpty, optional,
|
|
1255
|
+
export { WithDefaultError, map, multiple, nonEmpty, optional, withDefault };
|
package/dist/parser.cjs
CHANGED
|
@@ -731,7 +731,6 @@ exports.nonEmpty = require_modifiers.nonEmpty;
|
|
|
731
731
|
exports.object = require_constructs.object;
|
|
732
732
|
exports.option = require_primitives.option;
|
|
733
733
|
exports.optional = require_modifiers.optional;
|
|
734
|
-
exports.optionalStyleWrapperKey = require_modifiers.optionalStyleWrapperKey;
|
|
735
734
|
exports.or = require_constructs.or;
|
|
736
735
|
exports.parse = parse;
|
|
737
736
|
exports.parseAsync = parseAsync;
|
package/dist/parser.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import { ParserDependencyMetadata } from "./dependency-metadata.cjs";
|
|
|
8
8
|
import { DependencyRuntimeContext, RuntimeNode } from "./dependency-runtime.cjs";
|
|
9
9
|
import { InputTrace } from "./input-trace.cjs";
|
|
10
10
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.cjs";
|
|
11
|
-
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional,
|
|
11
|
+
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
|
|
12
12
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.cjs";
|
|
13
13
|
|
|
14
14
|
//#region src/parser.d.ts
|
|
@@ -934,4 +934,4 @@ declare function getDocPage(parser: Parser<"sync", unknown, unknown>, argsOrOpti
|
|
|
934
934
|
declare function getDocPage(parser: Parser<"async", unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): Promise<DocPage | undefined>;
|
|
935
935
|
declare function getDocPage<M extends Mode>(parser: Parser<M, unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): ModeValue<M, DocPage | undefined>;
|
|
936
936
|
//#endregion
|
|
937
|
-
export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional,
|
|
937
|
+
export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
|
package/dist/parser.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { ParserDependencyMetadata } from "./dependency-metadata.js";
|
|
|
8
8
|
import { DependencyRuntimeContext, RuntimeNode } from "./dependency-runtime.js";
|
|
9
9
|
import { InputTrace } from "./input-trace.js";
|
|
10
10
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
11
|
-
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional,
|
|
11
|
+
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
12
12
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
13
13
|
|
|
14
14
|
//#region src/parser.d.ts
|
|
@@ -934,4 +934,4 @@ declare function getDocPage(parser: Parser<"sync", unknown, unknown>, argsOrOpti
|
|
|
934
934
|
declare function getDocPage(parser: Parser<"async", unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): Promise<DocPage | undefined>;
|
|
935
935
|
declare function getDocPage<M extends Mode>(parser: Parser<M, unknown, unknown>, argsOrOptions?: readonly string[] | ParseOptions, options?: ParseOptions): ModeValue<M, DocPage | undefined>;
|
|
936
936
|
//#endregion
|
|
937
|
-
export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional,
|
|
937
|
+
export { ArgumentErrorOptions, ArgumentOptions, CombineModes, CommandErrorOptions, CommandOptions, ConditionalErrorOptions, ConditionalOptions, DocState, DuplicateOptionError, ExecutionContext, ExecutionPhase, FlagErrorOptions, FlagOptions, GroupOptions, InferMode, InferValue, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionOptions, OptionState, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserResult, PassThroughFormat, PassThroughOptions, Result, Suggestion, TupleOptions, WithDefaultError, WithDefaultOptions, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
|
package/dist/parser.js
CHANGED
|
@@ -4,7 +4,7 @@ import { cloneUsage, normalizeUsage } from "./usage.js";
|
|
|
4
4
|
import { cloneDocEntry, isDocEntryHidden } from "./doc.js";
|
|
5
5
|
import { dispatchByMode } from "./mode-dispatch.js";
|
|
6
6
|
import { createInputTrace } from "./input-trace.js";
|
|
7
|
-
import { WithDefaultError, map, multiple, nonEmpty, optional,
|
|
7
|
+
import { WithDefaultError, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
8
8
|
import { argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
9
9
|
import { collectExplicitSourceValues, collectExplicitSourceValuesAsync, createDependencyRuntimeContext } from "./dependency-runtime.js";
|
|
10
10
|
import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
@@ -702,4 +702,4 @@ function buildDocPage(parser, context, args) {
|
|
|
702
702
|
}
|
|
703
703
|
|
|
704
704
|
//#endregion
|
|
705
|
-
export { DuplicateOptionError, WithDefaultError, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional,
|
|
705
|
+
export { DuplicateOptionError, WithDefaultError, annotationWrapperRequiresSourceBindingKey, argument, command, composeWrappedSourceMetadata, concat, conditional, constant, createParserContext, defineInheritedAnnotationParser, defineSourceBindingOnlyAnnotationCompletionParser, fail, flag, getDelegatingSuggestRuntimeNodes, getDocPage, getDocPageAsync, getDocPageSync, getParserSuggestRuntimeNodes, group, inheritParentAnnotationsKey, longestMatch, map, merge, multiple, nonEmpty, object, option, optional, or, parse, parseAsync, parseSync, passThrough, suggest, suggestAsync, suggestSync, tuple, unmatchedNonCliDependencySourceStateMarker, withDefault };
|