@optique/core 0.10.7-dev.485 → 1.0.0-dev.1109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/dist/annotations.cjs +209 -1
- package/dist/annotations.d.cts +78 -1
- package/dist/annotations.d.ts +78 -1
- package/dist/annotations.js +201 -1
- package/dist/completion.cjs +186 -50
- package/dist/completion.js +186 -50
- package/dist/constructs.cjs +310 -78
- package/dist/constructs.d.cts +525 -644
- package/dist/constructs.d.ts +525 -644
- package/dist/constructs.js +311 -79
- package/dist/context.cjs +43 -3
- package/dist/context.d.cts +113 -5
- package/dist/context.d.ts +113 -5
- package/dist/context.js +41 -3
- package/dist/dependency.cjs +172 -66
- package/dist/dependency.d.cts +22 -2
- package/dist/dependency.d.ts +22 -2
- package/dist/dependency.js +172 -66
- package/dist/doc.cjs +46 -1
- package/dist/doc.d.cts +24 -0
- package/dist/doc.d.ts +24 -0
- package/dist/doc.js +46 -1
- package/dist/facade.cjs +702 -322
- package/dist/facade.d.cts +124 -190
- package/dist/facade.d.ts +124 -190
- package/dist/facade.js +703 -323
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -3
- package/dist/message.cjs +7 -4
- package/dist/message.js +7 -4
- package/dist/mode-dispatch.cjs +23 -1
- package/dist/mode-dispatch.d.cts +55 -0
- package/dist/mode-dispatch.d.ts +55 -0
- package/dist/mode-dispatch.js +21 -1
- package/dist/modifiers.cjs +210 -55
- package/dist/modifiers.js +211 -56
- package/dist/parser.cjs +80 -47
- package/dist/parser.d.cts +18 -3
- package/dist/parser.d.ts +18 -3
- package/dist/parser.js +82 -50
- package/dist/primitives.cjs +102 -37
- package/dist/primitives.d.cts +81 -24
- package/dist/primitives.d.ts +81 -24
- package/dist/primitives.js +103 -39
- package/dist/usage.cjs +88 -6
- package/dist/usage.d.cts +51 -13
- package/dist/usage.d.ts +51 -13
- package/dist/usage.js +85 -7
- package/dist/valueparser.cjs +371 -99
- package/dist/valueparser.d.cts +56 -7
- package/dist/valueparser.d.ts +56 -7
- package/dist/valueparser.js +371 -99
- package/package.json +10 -1
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ exports.envVar = require_message.envVar;
|
|
|
47
47
|
exports.extractArgumentMetavars = require_usage.extractArgumentMetavars;
|
|
48
48
|
exports.extractCommandNames = require_usage.extractCommandNames;
|
|
49
49
|
exports.extractOptionNames = require_usage.extractOptionNames;
|
|
50
|
+
exports.fail = require_primitives.fail;
|
|
50
51
|
exports.fish = require_completion.fish;
|
|
51
52
|
exports.flag = require_primitives.flag;
|
|
52
53
|
exports.float = require_valueparser.float;
|
|
@@ -71,8 +72,11 @@ exports.isDeferredParseState = require_dependency.isDeferredParseState;
|
|
|
71
72
|
exports.isDependencySource = require_dependency.isDependencySource;
|
|
72
73
|
exports.isDependencySourceState = require_dependency.isDependencySourceState;
|
|
73
74
|
exports.isDerivedValueParser = require_dependency.isDerivedValueParser;
|
|
75
|
+
exports.isDocHidden = require_usage.isDocHidden;
|
|
74
76
|
exports.isNonEmptyString = require_nonempty.isNonEmptyString;
|
|
75
77
|
exports.isPendingDependencySourceState = require_dependency.isPendingDependencySourceState;
|
|
78
|
+
exports.isSuggestionHidden = require_usage.isSuggestionHidden;
|
|
79
|
+
exports.isUsageHidden = require_usage.isUsageHidden;
|
|
76
80
|
exports.isValueParser = require_valueparser.isValueParser;
|
|
77
81
|
exports.isWrappedDependencySource = require_dependency.isWrappedDependencySource;
|
|
78
82
|
exports.lineBreak = require_message.lineBreak;
|
|
@@ -82,6 +86,7 @@ exports.longestMatch = require_constructs.longestMatch;
|
|
|
82
86
|
exports.macAddress = require_valueparser.macAddress;
|
|
83
87
|
exports.map = require_modifiers.map;
|
|
84
88
|
exports.merge = require_constructs.merge;
|
|
89
|
+
exports.mergeHidden = require_usage.mergeHidden;
|
|
85
90
|
exports.message = require_message.message;
|
|
86
91
|
exports.metavar = require_message.metavar;
|
|
87
92
|
exports.multiple = require_modifiers.multiple;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Annotations, ParseOptions, annotationKey, getAnnotations } from "./annotations.cjs";
|
|
2
2
|
import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.cjs";
|
|
3
3
|
import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
|
|
4
|
-
import { OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, normalizeUsage } from "./usage.cjs";
|
|
4
|
+
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
|
|
5
5
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, formatDocPage } from "./doc.cjs";
|
|
6
6
|
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, 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, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.cjs";
|
|
7
|
-
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.cjs";
|
|
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
8
|
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
|
|
9
9
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.cjs";
|
|
10
|
-
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, flag, option, passThrough } from "./primitives.cjs";
|
|
10
|
+
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.cjs";
|
|
11
11
|
import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, ModeValue, Parser, ParserContext, ParserResult, Result, Suggestion, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.cjs";
|
|
12
12
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
|
|
13
13
|
import { ParserValuePlaceholder, SourceContext } from "./context.cjs";
|
|
14
|
-
import {
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions,
|
|
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, 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, 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, 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, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, 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, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Annotations, ParseOptions, annotationKey, getAnnotations } from "./annotations.js";
|
|
2
2
|
import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
3
3
|
import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
|
|
4
|
-
import { OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, normalizeUsage } from "./usage.js";
|
|
4
|
+
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
5
5
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, formatDocPage } from "./doc.js";
|
|
6
6
|
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, 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, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
|
|
7
|
-
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
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
8
|
import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
9
9
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
|
|
10
|
-
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, flag, option, passThrough } from "./primitives.js";
|
|
10
|
+
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
11
11
|
import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, ModeValue, Parser, ParserContext, ParserResult, Result, Suggestion, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.js";
|
|
12
12
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
13
13
|
import { ParserValuePlaceholder, SourceContext } from "./context.js";
|
|
14
|
-
import {
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions,
|
|
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, 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, 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, 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, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, 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, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import { annotationKey, getAnnotations } from "./annotations.js";
|
|
|
2
2
|
import { commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
|
|
3
3
|
import { bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
4
4
|
import { DependencyRegistry, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
|
|
5
|
-
import { extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, normalizeUsage } from "./usage.js";
|
|
5
|
+
import { extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
6
6
|
import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
|
|
7
7
|
import { formatDocPage } from "./doc.js";
|
|
8
8
|
import { WithDefaultError, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
9
9
|
import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
10
10
|
import { choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
|
|
11
|
-
import { argument, command, constant, flag, option, passThrough } from "./primitives.js";
|
|
11
|
+
import { argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
|
|
12
12
|
import { getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.js";
|
|
13
13
|
import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
14
|
|
|
15
|
-
export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isNonEmptyString, isPendingDependencySourceState, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, 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, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
|
15
|
+
export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, 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, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
|
package/dist/message.cjs
CHANGED
|
@@ -254,10 +254,13 @@ function formatMessage(msg, options = {}) {
|
|
|
254
254
|
if (rawText.includes("\n\n")) {
|
|
255
255
|
const paragraphs = rawText.split(/\n\n+/);
|
|
256
256
|
for (let paragraphIndex = 0; paragraphIndex < paragraphs.length; paragraphIndex++) {
|
|
257
|
-
if (paragraphIndex > 0)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
if (paragraphIndex > 0) {
|
|
258
|
+
const breakText = isAfterLineBreak && paragraphIndex === 1 ? "\n" : "\n\n";
|
|
259
|
+
yield {
|
|
260
|
+
text: breakText,
|
|
261
|
+
width: -1
|
|
262
|
+
};
|
|
263
|
+
}
|
|
261
264
|
const paragraph = paragraphs[paragraphIndex].replace(/\n/g, " ");
|
|
262
265
|
wordPattern.lastIndex = 0;
|
|
263
266
|
while (true) {
|
package/dist/message.js
CHANGED
|
@@ -253,10 +253,13 @@ function formatMessage(msg, options = {}) {
|
|
|
253
253
|
if (rawText.includes("\n\n")) {
|
|
254
254
|
const paragraphs = rawText.split(/\n\n+/);
|
|
255
255
|
for (let paragraphIndex = 0; paragraphIndex < paragraphs.length; paragraphIndex++) {
|
|
256
|
-
if (paragraphIndex > 0)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
if (paragraphIndex > 0) {
|
|
257
|
+
const breakText = isAfterLineBreak && paragraphIndex === 1 ? "\n" : "\n\n";
|
|
258
|
+
yield {
|
|
259
|
+
text: breakText,
|
|
260
|
+
width: -1
|
|
261
|
+
};
|
|
262
|
+
}
|
|
260
263
|
const paragraph = paragraphs[paragraphIndex].replace(/\n/g, " ");
|
|
261
264
|
wordPattern.lastIndex = 0;
|
|
262
265
|
while (true) {
|
package/dist/mode-dispatch.cjs
CHANGED
|
@@ -18,6 +18,26 @@ function dispatchByMode(mode, syncFn, asyncFn) {
|
|
|
18
18
|
if (mode === "async") return asyncFn();
|
|
19
19
|
return syncFn();
|
|
20
20
|
}
|
|
21
|
+
function wrapForMode(mode, value) {
|
|
22
|
+
if (mode === "async") return Promise.resolve(value);
|
|
23
|
+
if (value instanceof Promise) throw new TypeError("Synchronous mode cannot wrap Promise value.");
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Maps a mode-wrapped value while preserving its execution mode.
|
|
28
|
+
*
|
|
29
|
+
* @param mode The execution mode.
|
|
30
|
+
* @param value The mode-wrapped value to transform.
|
|
31
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
32
|
+
* @returns The mapped value with correct mode wrapping.
|
|
33
|
+
* @internal
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
function mapModeValue(mode, value, mapFn) {
|
|
37
|
+
if (mode === "async") return Promise.resolve(value).then(mapFn);
|
|
38
|
+
if (value instanceof Promise) throw new TypeError("Synchronous mode cannot map Promise value.");
|
|
39
|
+
return mapFn(value);
|
|
40
|
+
}
|
|
21
41
|
/**
|
|
22
42
|
* Dispatches iterable to sync or async implementation based on mode.
|
|
23
43
|
*
|
|
@@ -35,4 +55,6 @@ function dispatchIterableByMode(mode, syncFn, asyncFn) {
|
|
|
35
55
|
|
|
36
56
|
//#endregion
|
|
37
57
|
exports.dispatchByMode = dispatchByMode;
|
|
38
|
-
exports.dispatchIterableByMode = dispatchIterableByMode;
|
|
58
|
+
exports.dispatchIterableByMode = dispatchIterableByMode;
|
|
59
|
+
exports.mapModeValue = mapModeValue;
|
|
60
|
+
exports.wrapForMode = wrapForMode;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Mode, ModeIterable, ModeValue } from "./parser.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/mode-dispatch.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dispatches to sync or async implementation based on mode.
|
|
7
|
+
*
|
|
8
|
+
* This function encapsulates the necessary type assertions when branching
|
|
9
|
+
* on runtime mode values. TypeScript cannot narrow `ModeValue<M, T>` based
|
|
10
|
+
* on `mode === "async"` checks, so we must use type assertions.
|
|
11
|
+
*
|
|
12
|
+
* @param mode The execution mode.
|
|
13
|
+
* @param syncFn Function to call for sync execution.
|
|
14
|
+
* @param asyncFn Function to call for async execution.
|
|
15
|
+
* @returns The result with correct mode wrapping.
|
|
16
|
+
* @internal
|
|
17
|
+
* @since 0.10.0
|
|
18
|
+
*/
|
|
19
|
+
declare function dispatchByMode<M extends Mode, T>(mode: M, syncFn: () => T, asyncFn: () => Promise<T>): ModeValue<M, T>;
|
|
20
|
+
/**
|
|
21
|
+
* Wraps a value so it matches the parser execution mode.
|
|
22
|
+
*
|
|
23
|
+
* @param mode The execution mode.
|
|
24
|
+
* @param value The value to wrap.
|
|
25
|
+
* @returns The wrapped value with correct mode semantics.
|
|
26
|
+
* @internal
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
*/
|
|
29
|
+
declare function wrapForMode<T>(mode: "sync", value: T | Promise<T>): T;
|
|
30
|
+
declare function wrapForMode<T>(mode: "async", value: T | Promise<T>): Promise<T>;
|
|
31
|
+
declare function wrapForMode<M extends Mode, T>(mode: M, value: T | Promise<T>): ModeValue<M, T>;
|
|
32
|
+
/**
|
|
33
|
+
* Maps a mode-wrapped value while preserving its execution mode.
|
|
34
|
+
*
|
|
35
|
+
* @param mode The execution mode.
|
|
36
|
+
* @param value The mode-wrapped value to transform.
|
|
37
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
38
|
+
* @returns The mapped value with correct mode wrapping.
|
|
39
|
+
* @internal
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*/
|
|
42
|
+
declare function mapModeValue<M extends Mode, T, U>(mode: M, value: ModeValue<M, T>, mapFn: (value: T) => U): ModeValue<M, U>;
|
|
43
|
+
/**
|
|
44
|
+
* Dispatches iterable to sync or async implementation based on mode.
|
|
45
|
+
*
|
|
46
|
+
* @param mode The execution mode.
|
|
47
|
+
* @param syncFn Function returning sync iterable.
|
|
48
|
+
* @param asyncFn Function returning async iterable.
|
|
49
|
+
* @returns The iterable with correct mode wrapping.
|
|
50
|
+
* @internal
|
|
51
|
+
* @since 0.10.0
|
|
52
|
+
*/
|
|
53
|
+
declare function dispatchIterableByMode<M extends Mode, T>(mode: M, syncFn: () => Iterable<T>, asyncFn: () => AsyncIterable<T>): ModeIterable<M, T>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Mode, ModeIterable, ModeValue } from "./parser.js";
|
|
2
|
+
|
|
3
|
+
//#region src/mode-dispatch.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Dispatches to sync or async implementation based on mode.
|
|
7
|
+
*
|
|
8
|
+
* This function encapsulates the necessary type assertions when branching
|
|
9
|
+
* on runtime mode values. TypeScript cannot narrow `ModeValue<M, T>` based
|
|
10
|
+
* on `mode === "async"` checks, so we must use type assertions.
|
|
11
|
+
*
|
|
12
|
+
* @param mode The execution mode.
|
|
13
|
+
* @param syncFn Function to call for sync execution.
|
|
14
|
+
* @param asyncFn Function to call for async execution.
|
|
15
|
+
* @returns The result with correct mode wrapping.
|
|
16
|
+
* @internal
|
|
17
|
+
* @since 0.10.0
|
|
18
|
+
*/
|
|
19
|
+
declare function dispatchByMode<M extends Mode, T>(mode: M, syncFn: () => T, asyncFn: () => Promise<T>): ModeValue<M, T>;
|
|
20
|
+
/**
|
|
21
|
+
* Wraps a value so it matches the parser execution mode.
|
|
22
|
+
*
|
|
23
|
+
* @param mode The execution mode.
|
|
24
|
+
* @param value The value to wrap.
|
|
25
|
+
* @returns The wrapped value with correct mode semantics.
|
|
26
|
+
* @internal
|
|
27
|
+
* @since 1.0.0
|
|
28
|
+
*/
|
|
29
|
+
declare function wrapForMode<T>(mode: "sync", value: T | Promise<T>): T;
|
|
30
|
+
declare function wrapForMode<T>(mode: "async", value: T | Promise<T>): Promise<T>;
|
|
31
|
+
declare function wrapForMode<M extends Mode, T>(mode: M, value: T | Promise<T>): ModeValue<M, T>;
|
|
32
|
+
/**
|
|
33
|
+
* Maps a mode-wrapped value while preserving its execution mode.
|
|
34
|
+
*
|
|
35
|
+
* @param mode The execution mode.
|
|
36
|
+
* @param value The mode-wrapped value to transform.
|
|
37
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
38
|
+
* @returns The mapped value with correct mode wrapping.
|
|
39
|
+
* @internal
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
*/
|
|
42
|
+
declare function mapModeValue<M extends Mode, T, U>(mode: M, value: ModeValue<M, T>, mapFn: (value: T) => U): ModeValue<M, U>;
|
|
43
|
+
/**
|
|
44
|
+
* Dispatches iterable to sync or async implementation based on mode.
|
|
45
|
+
*
|
|
46
|
+
* @param mode The execution mode.
|
|
47
|
+
* @param syncFn Function returning sync iterable.
|
|
48
|
+
* @param asyncFn Function returning async iterable.
|
|
49
|
+
* @returns The iterable with correct mode wrapping.
|
|
50
|
+
* @internal
|
|
51
|
+
* @since 0.10.0
|
|
52
|
+
*/
|
|
53
|
+
declare function dispatchIterableByMode<M extends Mode, T>(mode: M, syncFn: () => Iterable<T>, asyncFn: () => AsyncIterable<T>): ModeIterable<M, T>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode };
|
package/dist/mode-dispatch.js
CHANGED
|
@@ -17,6 +17,26 @@ function dispatchByMode(mode, syncFn, asyncFn) {
|
|
|
17
17
|
if (mode === "async") return asyncFn();
|
|
18
18
|
return syncFn();
|
|
19
19
|
}
|
|
20
|
+
function wrapForMode(mode, value) {
|
|
21
|
+
if (mode === "async") return Promise.resolve(value);
|
|
22
|
+
if (value instanceof Promise) throw new TypeError("Synchronous mode cannot wrap Promise value.");
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Maps a mode-wrapped value while preserving its execution mode.
|
|
27
|
+
*
|
|
28
|
+
* @param mode The execution mode.
|
|
29
|
+
* @param value The mode-wrapped value to transform.
|
|
30
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
31
|
+
* @returns The mapped value with correct mode wrapping.
|
|
32
|
+
* @internal
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
*/
|
|
35
|
+
function mapModeValue(mode, value, mapFn) {
|
|
36
|
+
if (mode === "async") return Promise.resolve(value).then(mapFn);
|
|
37
|
+
if (value instanceof Promise) throw new TypeError("Synchronous mode cannot map Promise value.");
|
|
38
|
+
return mapFn(value);
|
|
39
|
+
}
|
|
20
40
|
/**
|
|
21
41
|
* Dispatches iterable to sync or async implementation based on mode.
|
|
22
42
|
*
|
|
@@ -33,4 +53,4 @@ function dispatchIterableByMode(mode, syncFn, asyncFn) {
|
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
//#endregion
|
|
36
|
-
export { dispatchByMode, dispatchIterableByMode };
|
|
56
|
+
export { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode };
|