@optique/core 1.4.0-dev.2614 → 1.4.0-dev.2618
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 +86 -143
- package/dist/constructs.js +86 -143
- package/dist/execution-context.cjs +1 -2
- package/dist/execution-context.js +1 -3
- package/dist/facade.cjs +140 -6
- package/dist/facade.d.cts +32 -2
- package/dist/facade.d.ts +32 -2
- package/dist/facade.js +141 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/modifiers.cjs +4 -5
- package/dist/modifiers.js +4 -5
- package/dist/primitives.cjs +26 -68
- package/dist/primitives.d.cts +3 -3
- package/dist/primitives.d.ts +3 -3
- package/dist/primitives.js +26 -68
- package/dist/usage-internals.cjs +0 -73
- package/dist/usage-internals.js +1 -71
- package/package.json +2 -2
- package/skills/optique/SKILL.md +12 -12
- package/dist/short-option.cjs +0 -283
- package/dist/short-option.js +0 -270
package/dist/facade.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { injectAnnotations } from "./internal/annotations.js";
|
|
2
2
|
import { cacheTerminalTheme, renderTerminalTerm } from "./terminal-internal.js";
|
|
3
3
|
import { measureText, spaceAfterLabel } from "./text-layout.js";
|
|
4
|
-
import { validateCommandNames, validateContextIds, validateMetaNameCollisions, validateOptionNames, validateProgramName } from "./validate.js";
|
|
5
|
-
import { cloneUsage, formatUsage, isSuggestionHidden, normalizeUsage } from "./usage.js";
|
|
4
|
+
import { validateCommandNames, validateContextIds, validateLabel, validateMetaNameCollisions, validateOptionNames, validateProgramName } from "./validate.js";
|
|
5
|
+
import { cloneUsage, formatUsage, formatUsageTerm, isSuggestionHidden, normalizeUsage } from "./usage.js";
|
|
6
6
|
import { hasAutomaticWidth, minimumUsageWidth, withAutomaticWidth } from "./terminal-width.js";
|
|
7
7
|
import { commandLine, lineBreak, message, optionName, text, value } from "./message.js";
|
|
8
8
|
import { renderErrorMessage } from "./message-renderer.js";
|
|
9
|
-
import { formatDocPage } from "./doc.js";
|
|
9
|
+
import { formatDocPage, isDocEntryHidden } from "./doc.js";
|
|
10
10
|
import { dispatchByMode } from "./internal/mode-dispatch.js";
|
|
11
11
|
import { collectExplicitSourceValues, collectExplicitSourceValuesAsync, createDependencyRuntimeContext } from "./dependency-runtime.js";
|
|
12
12
|
import { createInputTrace } from "./input-trace.js";
|
|
13
13
|
import { attemptParseAsync, attemptParseSync, createEffectfulCompletionSession, createParserContext, getDocPage } from "./internal/parser.js";
|
|
14
14
|
import { bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
15
|
-
import { collectActiveOptionNames, collectRootOptionNames } from "./usage-internals.js";
|
|
16
15
|
import { allowDuplicateLeadingCommandNamesKey, hiddenCommandAliasesKey } from "./internal/command-alias.js";
|
|
17
16
|
import { completeOrExtractPhase2Seed } from "./phase2-seed.js";
|
|
18
17
|
import { multiple, optional, withDefault } from "./modifiers.js";
|
|
@@ -758,9 +757,76 @@ function collectActiveValueOptionNames(usage, commandPath, includeDirectAfterCom
|
|
|
758
757
|
for (const name of optionNames.flag) names.delete(name);
|
|
759
758
|
return names;
|
|
760
759
|
}
|
|
760
|
+
function collectRootOptionNames(usage, names, rootLeadingNames) {
|
|
761
|
+
for (const term of usage) collectRootOptionNamesFromTerm(term, names, rootLeadingNames);
|
|
762
|
+
}
|
|
763
|
+
function collectRootOptionNamesFromTerm(term, names, rootLeadingNames) {
|
|
764
|
+
switch (term.type) {
|
|
765
|
+
case "option":
|
|
766
|
+
for (const name of term.names) {
|
|
767
|
+
if (!rootLeadingNames.has(name)) continue;
|
|
768
|
+
if (term.metavar != null) names.value.add(name);
|
|
769
|
+
else names.flag.add(name);
|
|
770
|
+
}
|
|
771
|
+
return;
|
|
772
|
+
case "optional":
|
|
773
|
+
case "multiple":
|
|
774
|
+
case "sequence":
|
|
775
|
+
collectRootOptionNames(term.terms, names, rootLeadingNames);
|
|
776
|
+
return;
|
|
777
|
+
case "exclusive":
|
|
778
|
+
for (const branch of term.terms) collectRootOptionNames(branch, names, rootLeadingNames);
|
|
779
|
+
return;
|
|
780
|
+
case "argument":
|
|
781
|
+
case "command":
|
|
782
|
+
case "literal":
|
|
783
|
+
case "passthrough":
|
|
784
|
+
case "ellipsis": return;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function collectActiveOptionNames(usage, commandPath, names, fromExclusive, includeDirectAfterCommandOptions) {
|
|
788
|
+
if (commandPath.length === 0) {
|
|
789
|
+
collectOptionNamesAtCurrentCommandDepth(usage, names, false);
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
const [commandName, ...rest] = commandPath;
|
|
793
|
+
for (let i = 0; i < usage.length; i++) {
|
|
794
|
+
const term = usage[i];
|
|
795
|
+
if (term.type === "command" && term.name === commandName) {
|
|
796
|
+
const remainingUsage = usage.slice(i + 1);
|
|
797
|
+
if (rest.length === 0) collectOptionNamesAtCurrentCommandDepth(remainingUsage, names, !fromExclusive && includeDirectAfterCommandOptions);
|
|
798
|
+
else collectActiveOptionNames(remainingUsage, rest, names, fromExclusive, includeDirectAfterCommandOptions);
|
|
799
|
+
} else if (term.type === "exclusive") for (const branch of term.terms) collectActiveOptionNames(branch, commandPath, names, true, includeDirectAfterCommandOptions);
|
|
800
|
+
else if (term.type === "optional" || term.type === "multiple" || term.type === "sequence") collectActiveOptionNames(term.terms, commandPath, names, fromExclusive, includeDirectAfterCommandOptions);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
761
803
|
function isRootOptionToken(token, rootOptionSuggestions) {
|
|
762
804
|
return token != null && rootOptionSuggestions.some((suggestion) => token === suggestion.text || token.startsWith(`${suggestion.text}=`));
|
|
763
805
|
}
|
|
806
|
+
function collectOptionNamesAtCurrentCommandDepth(usage, names, afterMatchedCommand) {
|
|
807
|
+
for (const term of usage) if (collectOptionNamesAtCurrentCommandDepthFromTerm(term, names, afterMatchedCommand)) return;
|
|
808
|
+
}
|
|
809
|
+
function collectOptionNamesAtCurrentCommandDepthFromTerm(term, names, afterMatchedCommand) {
|
|
810
|
+
switch (term.type) {
|
|
811
|
+
case "command": return !afterMatchedCommand;
|
|
812
|
+
case "option":
|
|
813
|
+
if (term.metavar != null) for (const name of term.names) names.value.add(name);
|
|
814
|
+
else for (const name of term.names) names.flag.add(name);
|
|
815
|
+
return false;
|
|
816
|
+
case "optional":
|
|
817
|
+
case "multiple":
|
|
818
|
+
case "sequence":
|
|
819
|
+
collectOptionNamesAtCurrentCommandDepth(term.terms, names, afterMatchedCommand);
|
|
820
|
+
return false;
|
|
821
|
+
case "exclusive":
|
|
822
|
+
for (const branch of term.terms) collectOptionNamesAtCurrentCommandDepth(branch, names, false);
|
|
823
|
+
return false;
|
|
824
|
+
case "argument":
|
|
825
|
+
case "literal":
|
|
826
|
+
case "passthrough":
|
|
827
|
+
case "ellipsis": return false;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
764
830
|
function getRootMetaOptionSuggestions(helpOptionConfig, helpOptionNames, versionOptionConfig, versionOptionNames) {
|
|
765
831
|
const suggestions = [];
|
|
766
832
|
if (helpOptionConfig != null && !isSuggestionHidden(helpOptionConfig.hidden)) suggestions.push(...helpOptionNames.map((name) => ({
|
|
@@ -818,7 +884,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
818
884
|
options = optionsParam ?? {};
|
|
819
885
|
}
|
|
820
886
|
validateProgramName(programName);
|
|
821
|
-
const { colors, messageFormatter, theme: requestedTheme, maxWidth: requestedMaxWidth, termWidth, showDefault, showChoices, sectionOrder, showUsage, usageLine, commandList = "recursive", aboveError = "usage", onError = () => {
|
|
887
|
+
const { colors, messageFormatter, theme: requestedTheme, maxWidth: requestedMaxWidth, termWidth, showDefault, showChoices, sectionOrder, helpSections, showUsage, usageLine, commandList = "recursive", aboveError = "usage", onError = () => {
|
|
822
888
|
throw new RunParserError("Failed to parse command line arguments.");
|
|
823
889
|
}, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
|
|
824
890
|
let maxWidth = requestedMaxWidth;
|
|
@@ -850,6 +916,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
850
916
|
const onCompletion = options.completion?.onShow ?? (() => ({}));
|
|
851
917
|
const onCompletionResult = (code) => onCompletion(code);
|
|
852
918
|
const onErrorResult = (code, error) => onError(code, error);
|
|
919
|
+
for (const label of [helpSections?.commands, helpSections?.options]) if (label !== void 0) validateLabel(label);
|
|
853
920
|
if (helpOptionConfig?.names) validateOptionNames(helpOptionConfig.names, "Help option");
|
|
854
921
|
if (helpCommandConfig?.names) validateCommandNames(helpCommandConfig.names, "Help command");
|
|
855
922
|
if (versionOptionConfig?.names) validateOptionNames(versionOptionConfig.names, "Version option");
|
|
@@ -1022,7 +1089,8 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1022
1089
|
bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
|
|
1023
1090
|
footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
|
|
1024
1091
|
}, commandList, isTopLevel);
|
|
1025
|
-
const
|
|
1092
|
+
const groupedDoc = applyHelpSections(augmentedDoc, helpSections);
|
|
1093
|
+
const renderedDoc = isTopLevel && usageLine != null ? applyUsageLine(groupedDoc, usageLine) : groupedDoc;
|
|
1026
1094
|
stdout(formatDocPage(programName, renderedDoc, formatOptions({
|
|
1027
1095
|
messageFormatter,
|
|
1028
1096
|
theme,
|
|
@@ -1098,7 +1166,8 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1098
1166
|
footer: footer ?? doc.footer
|
|
1099
1167
|
}, commandList, isTopLevel);
|
|
1100
1168
|
const defaultRootUsage = typeof usageLine === "function" && (options.help || options.version || options.completion) ? normalizeUsage(getRootHelpGeneratorParser().usage) : augmentedDoc.usage ?? [];
|
|
1101
|
-
const
|
|
1169
|
+
const groupedDoc = applyHelpSections(augmentedDoc, helpSections);
|
|
1170
|
+
const renderedDoc = isTopLevel && usageLine != null ? applyUsageLine(groupedDoc, usageLine, defaultRootUsage) : groupedDoc;
|
|
1102
1171
|
stderr(formatDocPage(programName, renderedDoc, formatOptions({
|
|
1103
1172
|
messageFormatter,
|
|
1104
1173
|
theme,
|
|
@@ -1185,6 +1254,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1185
1254
|
* @returns The parsed result if successful.
|
|
1186
1255
|
* @throws {TypeError} If an async parser is passed at runtime. Use
|
|
1187
1256
|
* {@link runParser} or {@link runParserAsync} for async parsers.
|
|
1257
|
+
* @throws {TypeError} If a `helpSections` label is invalid.
|
|
1188
1258
|
* @since 0.9.0
|
|
1189
1259
|
*/
|
|
1190
1260
|
function runParserSync(parser, programName, args, options) {
|
|
@@ -1207,6 +1277,7 @@ function runParserSync(parser, programName, args, options) {
|
|
|
1207
1277
|
* @param options Configuration options for customizing behavior.
|
|
1208
1278
|
* @throws {RangeError} If rendering help or errors encounters an invalid theme
|
|
1209
1279
|
* color, even when colors are disabled.
|
|
1280
|
+
* @throws {TypeError} If a `helpSections` label is invalid.
|
|
1210
1281
|
* @returns A Promise of the parsed result if successful.
|
|
1211
1282
|
* @since 0.9.0
|
|
1212
1283
|
*/
|
|
@@ -1221,6 +1292,66 @@ function applyUsageLine(doc, usageLine, defaultUsageLine = doc.usage ?? []) {
|
|
|
1221
1292
|
usage: normalizeUsage(customUsageLine)
|
|
1222
1293
|
};
|
|
1223
1294
|
}
|
|
1295
|
+
/** Prepares the runner's final page without changing parser documentation. */
|
|
1296
|
+
function applyHelpSections(doc, labels) {
|
|
1297
|
+
if (labels == null || labels.commands == null && labels.options == null) return doc;
|
|
1298
|
+
const visible = (entry) => !isDocEntryHidden(entry) && formatUsageTerm(entry.term, { context: "doc" }).trim() !== "";
|
|
1299
|
+
if (!doc.sections.some((section) => section.entries.some((entry) => entry.term.type === "command" && visible(entry)))) return doc;
|
|
1300
|
+
const existingTitles = new Set(doc.sections.flatMap((section) => section.title == null ? [] : [section.title]));
|
|
1301
|
+
const additions = /* @__PURE__ */ new Map();
|
|
1302
|
+
const residuals = /* @__PURE__ */ new Map();
|
|
1303
|
+
const newSections = /* @__PURE__ */ new Map();
|
|
1304
|
+
for (const section of doc.sections) {
|
|
1305
|
+
if (section.title != null) continue;
|
|
1306
|
+
const commands = [];
|
|
1307
|
+
const options = [];
|
|
1308
|
+
const remaining = [];
|
|
1309
|
+
for (const entry of section.entries) if (entry.term.type === "command" && labels.commands != null && visible(entry)) commands.push(entry);
|
|
1310
|
+
else if (entry.term.type === "option" && labels.options != null && visible(entry)) options.push(entry);
|
|
1311
|
+
else remaining.push(entry);
|
|
1312
|
+
if (commands.length === 0 && options.length === 0) continue;
|
|
1313
|
+
residuals.set(section, remaining);
|
|
1314
|
+
for (const [label, entries] of [[labels.commands, commands], [labels.options, options]]) {
|
|
1315
|
+
if (label == null || entries.length === 0) continue;
|
|
1316
|
+
const previous = additions.get(label);
|
|
1317
|
+
if (previous != null) previous.push(...entries);
|
|
1318
|
+
else {
|
|
1319
|
+
additions.set(label, entries);
|
|
1320
|
+
if (!existingTitles.has(label)) {
|
|
1321
|
+
const titles = newSections.get(section) ?? [];
|
|
1322
|
+
titles.push(label);
|
|
1323
|
+
newSections.set(section, titles);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
if (additions.size === 0) return doc;
|
|
1329
|
+
const sections = [];
|
|
1330
|
+
for (const section of doc.sections) {
|
|
1331
|
+
if (section.title != null) {
|
|
1332
|
+
const entries$1 = additions.get(section.title);
|
|
1333
|
+
sections.push(entries$1 == null ? section : {
|
|
1334
|
+
...section,
|
|
1335
|
+
entries: [...section.entries, ...entries$1]
|
|
1336
|
+
});
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
for (const title of newSections.get(section) ?? []) sections.push({
|
|
1340
|
+
title,
|
|
1341
|
+
entries: additions.get(title) ?? []
|
|
1342
|
+
});
|
|
1343
|
+
const entries = residuals.get(section);
|
|
1344
|
+
if (entries == null) sections.push(section);
|
|
1345
|
+
else if (entries.length > 0) sections.push({
|
|
1346
|
+
...section,
|
|
1347
|
+
entries
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
return {
|
|
1351
|
+
...doc,
|
|
1352
|
+
sections
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1224
1355
|
function maybeCollapseCommandList(doc, commandList, isTopLevel) {
|
|
1225
1356
|
if (commandList !== "top-level" || !isTopLevel) return doc;
|
|
1226
1357
|
return {
|
|
@@ -1556,6 +1687,7 @@ async function runWithBody(parser, programName, contexts, args, options) {
|
|
|
1556
1687
|
* @param programName Name of the program for help/error output.
|
|
1557
1688
|
* @param contexts Source contexts to use (priority: earlier overrides later).
|
|
1558
1689
|
* @param options Run options including args, help, version, etc.
|
|
1690
|
+
* @throws {TypeError} If a `helpSections` label is invalid.
|
|
1559
1691
|
* @throws {RangeError} If rendering help or errors encounters an invalid theme
|
|
1560
1692
|
* color, even when colors are disabled.
|
|
1561
1693
|
* @returns Promise that resolves to the parsed result.
|
|
@@ -1656,6 +1788,7 @@ function runWithSyncBody(parser, programName, contexts, args, options) {
|
|
|
1656
1788
|
* @param programName Name of the program for help/error output.
|
|
1657
1789
|
* @param contexts Source contexts to use (priority: earlier overrides later).
|
|
1658
1790
|
* @param options Run options including args, help, version, etc.
|
|
1791
|
+
* @throws {TypeError} If a `helpSections` label is invalid.
|
|
1659
1792
|
* @throws {RangeError} If rendering help or errors encounters an invalid theme
|
|
1660
1793
|
* color, even when colors are disabled.
|
|
1661
1794
|
* @returns The parsed result.
|
|
@@ -1707,6 +1840,7 @@ function runWithSync(parser, programName, contexts, options) {
|
|
|
1707
1840
|
* @param programName Name of the program for help/error output.
|
|
1708
1841
|
* @param contexts Source contexts to use (priority: earlier overrides later).
|
|
1709
1842
|
* @param options Run options including args, help, version, etc.
|
|
1843
|
+
* @throws {TypeError} If a `helpSections` label is invalid.
|
|
1710
1844
|
* @throws {RangeError} If rendering help or errors encounters an invalid theme
|
|
1711
1845
|
* color, even when colors are disabled.
|
|
1712
1846
|
* @returns Promise that resolves to the parsed result.
|
package/dist/index.d.cts
CHANGED
|
@@ -11,6 +11,6 @@ import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser,
|
|
|
11
11
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, SeqOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.cjs";
|
|
12
12
|
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.cjs";
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
|
|
14
|
-
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
14
|
+
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, HelpSectionsOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
15
15
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
|
|
16
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser,
|
|
|
11
11
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, SeqOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.js";
|
|
12
12
|
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.js";
|
|
13
13
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
|
|
14
|
-
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
|
+
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, HelpSectionsOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
15
15
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
16
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
16
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/modifiers.cjs
CHANGED
|
@@ -4,7 +4,6 @@ const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
|
4
4
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
5
5
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
6
6
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
7
|
-
const require_short_option = require('./short-option.cjs');
|
|
8
7
|
const require_execution_context = require('./execution-context.cjs');
|
|
9
8
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
10
9
|
const require_dependency_metadata = require('./dependency-metadata.cjs');
|
|
@@ -479,7 +478,7 @@ function optional(parser) {
|
|
|
479
478
|
require_internal_parser.defineParseLanes(optionalParser, adaptOptionalStyleParseLanes(parser));
|
|
480
479
|
require_internal_parser.defineInheritedAnnotationParser(optionalParser);
|
|
481
480
|
require_internal_parser.defineSourceBindingOnlyAnnotationCompletionParser(optionalParser);
|
|
482
|
-
return fluent(
|
|
481
|
+
return fluent(optionalParser);
|
|
483
482
|
}
|
|
484
483
|
/**
|
|
485
484
|
* Error type for structured error messages in {@link withDefault} default value callbacks.
|
|
@@ -730,7 +729,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
730
729
|
require_internal_parser.defineParseLanes(withDefaultParser, adaptOptionalStyleParseLanes(parser));
|
|
731
730
|
require_internal_parser.defineInheritedAnnotationParser(withDefaultParser);
|
|
732
731
|
require_internal_parser.defineSourceBindingOnlyAnnotationCompletionParser(withDefaultParser);
|
|
733
|
-
return fluent(
|
|
732
|
+
return fluent(withDefaultParser);
|
|
734
733
|
}
|
|
735
734
|
/**
|
|
736
735
|
* Creates a parser that transforms the result value of another parser using
|
|
@@ -1715,7 +1714,7 @@ function multiple(parser, options = {}) {
|
|
|
1715
1714
|
enumerable: false
|
|
1716
1715
|
});
|
|
1717
1716
|
}
|
|
1718
|
-
return fluent(
|
|
1717
|
+
return fluent(resultParser);
|
|
1719
1718
|
}
|
|
1720
1719
|
/**
|
|
1721
1720
|
* Creates a parser that requires the wrapped parser to consume at least one
|
|
@@ -1851,7 +1850,7 @@ function nonEmpty(parser) {
|
|
|
1851
1850
|
enumerable: false
|
|
1852
1851
|
});
|
|
1853
1852
|
require_dependency_runtime.defineForwardedEffectfulSchedulingNodes(nonEmptyParser, parser);
|
|
1854
|
-
return fluent(
|
|
1853
|
+
return fluent(nonEmptyParser);
|
|
1855
1854
|
}
|
|
1856
1855
|
const fluentParserMarker = Symbol.for("@optique/core/fluent");
|
|
1857
1856
|
/**
|
package/dist/modifiers.js
CHANGED
|
@@ -4,7 +4,6 @@ import { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode } fro
|
|
|
4
4
|
import { defineForwardedEffectfulSchedulingNodes } from "./dependency-runtime.js";
|
|
5
5
|
import { defineInheritedAnnotationParser, defineParseLanes, defineSourceBindingOnlyAnnotationCompletionParser, getOwnParseLanes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
6
6
|
import { getDelegatedAnnotationState, hasDelegatedAnnotationCarrier, isAnnotationWrappedInitialState, normalizeDelegatedAnnotationState, normalizeNestedDelegatedAnnotationState } from "./annotation-state.js";
|
|
7
|
-
import { combinedOptionScope, repeatedOptionScope, scopeParser } from "./short-option.js";
|
|
8
7
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
9
8
|
import { completeOrExtractPhase2Seed, extractPhase2Seed, extractPhase2SeedKey, phase2SeedFromValueResult } from "./phase2-seed.js";
|
|
10
9
|
import { composeDependencyMetadata } from "./dependency-metadata.js";
|
|
@@ -479,7 +478,7 @@ function optional(parser) {
|
|
|
479
478
|
defineParseLanes(optionalParser, adaptOptionalStyleParseLanes(parser));
|
|
480
479
|
defineInheritedAnnotationParser(optionalParser);
|
|
481
480
|
defineSourceBindingOnlyAnnotationCompletionParser(optionalParser);
|
|
482
|
-
return fluent(
|
|
481
|
+
return fluent(optionalParser);
|
|
483
482
|
}
|
|
484
483
|
/**
|
|
485
484
|
* Error type for structured error messages in {@link withDefault} default value callbacks.
|
|
@@ -730,7 +729,7 @@ function withDefault(parser, defaultValue, options) {
|
|
|
730
729
|
defineParseLanes(withDefaultParser, adaptOptionalStyleParseLanes(parser));
|
|
731
730
|
defineInheritedAnnotationParser(withDefaultParser);
|
|
732
731
|
defineSourceBindingOnlyAnnotationCompletionParser(withDefaultParser);
|
|
733
|
-
return fluent(
|
|
732
|
+
return fluent(withDefaultParser);
|
|
734
733
|
}
|
|
735
734
|
/**
|
|
736
735
|
* Creates a parser that transforms the result value of another parser using
|
|
@@ -1715,7 +1714,7 @@ function multiple(parser, options = {}) {
|
|
|
1715
1714
|
enumerable: false
|
|
1716
1715
|
});
|
|
1717
1716
|
}
|
|
1718
|
-
return fluent(
|
|
1717
|
+
return fluent(resultParser);
|
|
1719
1718
|
}
|
|
1720
1719
|
/**
|
|
1721
1720
|
* Creates a parser that requires the wrapped parser to consume at least one
|
|
@@ -1851,7 +1850,7 @@ function nonEmpty(parser) {
|
|
|
1851
1850
|
enumerable: false
|
|
1852
1851
|
});
|
|
1853
1852
|
defineForwardedEffectfulSchedulingNodes(nonEmptyParser, parser);
|
|
1854
|
-
return fluent(
|
|
1853
|
+
return fluent(nonEmptyParser);
|
|
1855
1854
|
}
|
|
1856
1855
|
const fluentParserMarker = Symbol.for("@optique/core/fluent");
|
|
1857
1856
|
/**
|
package/dist/primitives.cjs
CHANGED
|
@@ -6,14 +6,13 @@ const require_mode_dispatch = require('./internal/mode-dispatch.cjs');
|
|
|
6
6
|
const require_internal_dependency = require('./internal/dependency.cjs');
|
|
7
7
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
8
8
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
9
|
-
const require_usage_internals = require('./usage-internals.cjs');
|
|
10
|
-
const require_short_option = require('./short-option.cjs');
|
|
11
9
|
const require_command_alias = require('./internal/command-alias.cjs');
|
|
12
10
|
const require_execution_context = require('./execution-context.cjs');
|
|
13
11
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
14
12
|
const require_dependency_metadata = require('./dependency-metadata.cjs');
|
|
15
13
|
const require_modifiers = require('./modifiers.cjs');
|
|
16
14
|
const require_suggestion = require('./suggestion.cjs');
|
|
15
|
+
const require_usage_internals = require('./usage-internals.cjs');
|
|
17
16
|
const require_valueparser = require('./valueparser.cjs');
|
|
18
17
|
|
|
19
18
|
//#region src/primitives.ts
|
|
@@ -257,25 +256,11 @@ function* getSuggestionsWithDependency(valueParser, prefix, dependencyRegistry,
|
|
|
257
256
|
*/
|
|
258
257
|
function* suggestOptionSync(optionNames$1, valueParser, hidden, description, context, prefix) {
|
|
259
258
|
if (hidden) return;
|
|
260
|
-
if (context.optionsTerminated) return;
|
|
261
|
-
const waitingForValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
|
|
262
|
-
if (valueParser != null && !waitingForValue && !isTerminalValueState(context.state)) {
|
|
263
|
-
const attached = require_short_option.attachedValuePrefix(context, prefix, optionNames$1);
|
|
264
|
-
if (attached != null) {
|
|
265
|
-
if (attached.value.length === 0 && optionNames$1.includes(prefix)) yield {
|
|
266
|
-
kind: "literal",
|
|
267
|
-
text: prefix,
|
|
268
|
-
...description != null ? { description } : {}
|
|
269
|
-
};
|
|
270
|
-
if (valueParser.suggest != null) for (const suggestion of getSuggestionsWithDependency(valueParser, attached.value, context.dependencyRegistry, context.exec)) yield require_short_option.prefixSuggestion(attached.head, suggestion);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
259
|
const equalsIndex = prefix.indexOf("=");
|
|
275
|
-
if (equalsIndex >= 0
|
|
260
|
+
if (equalsIndex >= 0) {
|
|
276
261
|
const optionPart = prefix.slice(0, equalsIndex);
|
|
277
262
|
const valuePart = prefix.slice(equalsIndex + 1);
|
|
278
|
-
if (optionNames$1.includes(optionPart)
|
|
263
|
+
if (optionNames$1.includes(optionPart)) {
|
|
279
264
|
if (valueParser && valueParser.suggest) {
|
|
280
265
|
const valueSuggestions = getSuggestionsWithDependency(valueParser, valuePart, context.dependencyRegistry, context.exec);
|
|
281
266
|
for (const suggestion of valueSuggestions) if (suggestion.kind === "literal") yield {
|
|
@@ -294,7 +279,7 @@ function* suggestOptionSync(optionNames$1, valueParser, hidden, description, con
|
|
|
294
279
|
const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
|
|
295
280
|
if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/") || prefix.startsWith("+"))) {
|
|
296
281
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
297
|
-
if (prefix === "-" &&
|
|
282
|
+
if (prefix === "-" && optionName$1.length !== 2) continue;
|
|
298
283
|
yield {
|
|
299
284
|
kind: "literal",
|
|
300
285
|
text: optionName$1,
|
|
@@ -356,25 +341,11 @@ async function* getSuggestionsWithDependencyAsync(valueParser, prefix, dependenc
|
|
|
356
341
|
*/
|
|
357
342
|
async function* suggestOptionAsync(optionNames$1, valueParser, hidden, description, context, prefix) {
|
|
358
343
|
if (hidden) return;
|
|
359
|
-
if (context.optionsTerminated) return;
|
|
360
|
-
const waitingForValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
|
|
361
|
-
if (valueParser != null && !waitingForValue && !isTerminalValueState(context.state)) {
|
|
362
|
-
const attached = require_short_option.attachedValuePrefix(context, prefix, optionNames$1);
|
|
363
|
-
if (attached != null) {
|
|
364
|
-
if (attached.value.length === 0 && optionNames$1.includes(prefix)) yield {
|
|
365
|
-
kind: "literal",
|
|
366
|
-
text: prefix,
|
|
367
|
-
...description != null ? { description } : {}
|
|
368
|
-
};
|
|
369
|
-
if (valueParser.suggest != null) for await (const suggestion of getSuggestionsWithDependencyAsync(valueParser, attached.value, context.dependencyRegistry, context.exec)) yield require_short_option.prefixSuggestion(attached.head, suggestion);
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
344
|
const equalsIndex = prefix.indexOf("=");
|
|
374
|
-
if (equalsIndex >= 0
|
|
345
|
+
if (equalsIndex >= 0) {
|
|
375
346
|
const optionPart = prefix.slice(0, equalsIndex);
|
|
376
347
|
const valuePart = prefix.slice(equalsIndex + 1);
|
|
377
|
-
if (optionNames$1.includes(optionPart)
|
|
348
|
+
if (optionNames$1.includes(optionPart)) {
|
|
378
349
|
if (valueParser && valueParser.suggest) {
|
|
379
350
|
const valueSuggestions = getSuggestionsWithDependencyAsync(valueParser, valuePart, context.dependencyRegistry, context.exec);
|
|
380
351
|
for await (const suggestion of valueSuggestions) if (suggestion.kind === "literal") yield {
|
|
@@ -393,7 +364,7 @@ async function* suggestOptionAsync(optionNames$1, valueParser, hidden, descripti
|
|
|
393
364
|
const expectingValue = context.buffer.length > 0 && optionNames$1.includes(context.buffer[context.buffer.length - 1]);
|
|
394
365
|
if (!expectingValue && (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/") || prefix.startsWith("+"))) {
|
|
395
366
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
396
|
-
if (prefix === "-" &&
|
|
367
|
+
if (prefix === "-" && optionName$1.length !== 2) continue;
|
|
397
368
|
yield {
|
|
398
369
|
kind: "literal",
|
|
399
370
|
text: optionName$1,
|
|
@@ -553,18 +524,10 @@ function option(...args) {
|
|
|
553
524
|
};
|
|
554
525
|
});
|
|
555
526
|
}
|
|
556
|
-
const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/") || name.startsWith("-") && name.length > 2
|
|
557
|
-
|
|
558
|
-
prefix: name.startsWith("/") ? `${name}:` : `${name}=`
|
|
559
|
-
}));
|
|
560
|
-
if (valueParser != null && optionNames$1.some((name) => /^-[^-]$/u.test(name) && context.buffer[0].startsWith(name)) && !require_short_option.fullNameOwnsToken(context, context.buffer[0])) {
|
|
561
|
-
for (const name of optionNames$1) if (/^-[^-]$/u.test(name)) prefixes.push({
|
|
562
|
-
optionName: name,
|
|
563
|
-
prefix: name
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
for (const { prefix, optionName: optionName$1 } of prefixes) {
|
|
527
|
+
const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/") || name.startsWith("-") && name.length > 2).map((name) => name.startsWith("/") ? `${name}:` : `${name}=`);
|
|
528
|
+
for (const prefix of prefixes) {
|
|
567
529
|
if (!context.buffer[0].startsWith(prefix)) continue;
|
|
530
|
+
const optionName$1 = prefix.slice(0, -1);
|
|
568
531
|
if (hasParsedOptionValue(context.state, valueParser)) return {
|
|
569
532
|
success: false,
|
|
570
533
|
consumed: 1,
|
|
@@ -603,9 +566,9 @@ function option(...args) {
|
|
|
603
566
|
});
|
|
604
567
|
}
|
|
605
568
|
if (valueParser == null) {
|
|
606
|
-
const shortOptions = optionNames$1.filter((name) => name.match(/^-[^-]$/
|
|
569
|
+
const shortOptions = optionNames$1.filter((name) => name.match(/^-[^-]$/));
|
|
607
570
|
for (const shortOption of shortOptions) {
|
|
608
|
-
if (!context.buffer[0].startsWith(shortOption)
|
|
571
|
+
if (!context.buffer[0].startsWith(shortOption)) continue;
|
|
609
572
|
if (hasParsedOptionValue(context.state, valueParser)) return {
|
|
610
573
|
success: false,
|
|
611
574
|
consumed: 1,
|
|
@@ -619,9 +582,9 @@ function option(...args) {
|
|
|
619
582
|
success: true,
|
|
620
583
|
value: true
|
|
621
584
|
},
|
|
622
|
-
buffer: [`-${context.buffer[0].slice(
|
|
585
|
+
buffer: [`-${context.buffer[0].slice(2)}`, ...context.buffer.slice(1)]
|
|
623
586
|
},
|
|
624
|
-
consumed: [context.buffer[0].slice(0,
|
|
587
|
+
consumed: [context.buffer[0].slice(0, 2)]
|
|
625
588
|
};
|
|
626
589
|
}
|
|
627
590
|
}
|
|
@@ -883,7 +846,7 @@ function flag(...args) {
|
|
|
883
846
|
consumed: context.buffer.slice(0, 1)
|
|
884
847
|
};
|
|
885
848
|
}
|
|
886
|
-
const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/") || name.startsWith("-") && name.length > 2
|
|
849
|
+
const prefixes = optionNames$1.filter((name) => name.startsWith("--") || name.startsWith("/") || name.startsWith("-") && name.length > 2).map((name) => name.startsWith("/") ? `${name}:` : `${name}=`);
|
|
887
850
|
for (const prefix of prefixes) if (context.buffer[0].startsWith(prefix)) {
|
|
888
851
|
const value = context.buffer[0].slice(prefix.length);
|
|
889
852
|
return {
|
|
@@ -892,9 +855,9 @@ function flag(...args) {
|
|
|
892
855
|
error: require_message.message`Flag ${require_message.optionName(prefix.slice(0, -1))} does not accept a value, but got: ${value}.`
|
|
893
856
|
};
|
|
894
857
|
}
|
|
895
|
-
const shortOptions = optionNames$1.filter((name) => name.match(/^-[^-]$/
|
|
858
|
+
const shortOptions = optionNames$1.filter((name) => name.match(/^-[^-]$/));
|
|
896
859
|
for (const shortOption of shortOptions) {
|
|
897
|
-
if (!context.buffer[0].startsWith(shortOption)
|
|
860
|
+
if (!context.buffer[0].startsWith(shortOption)) continue;
|
|
898
861
|
if (context.state?.success) return {
|
|
899
862
|
success: false,
|
|
900
863
|
consumed: 1,
|
|
@@ -908,9 +871,9 @@ function flag(...args) {
|
|
|
908
871
|
success: true,
|
|
909
872
|
value: true
|
|
910
873
|
},
|
|
911
|
-
buffer: [`-${context.buffer[0].slice(
|
|
874
|
+
buffer: [`-${context.buffer[0].slice(2)}`, ...context.buffer.slice(1)]
|
|
912
875
|
},
|
|
913
|
-
consumed: [context.buffer[0].slice(0,
|
|
876
|
+
consumed: [context.buffer[0].slice(0, 2)]
|
|
914
877
|
};
|
|
915
878
|
}
|
|
916
879
|
const invalidOption = context.buffer[0];
|
|
@@ -951,7 +914,7 @@ function flag(...args) {
|
|
|
951
914
|
const suggestions = [];
|
|
952
915
|
if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/") || prefix.startsWith("+")) {
|
|
953
916
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
954
|
-
if (prefix === "-" &&
|
|
917
|
+
if (prefix === "-" && optionName$1.length !== 2) continue;
|
|
955
918
|
suggestions.push({
|
|
956
919
|
kind: "literal",
|
|
957
920
|
text: optionName$1,
|
|
@@ -1102,7 +1065,7 @@ function negatableFlag(names, options = {}) {
|
|
|
1102
1065
|
const directValue = valueByName.get(context.buffer[0]);
|
|
1103
1066
|
if (directValue != null) return parseMatchedNegatableFlag(context, context.buffer[0], directValue, context.buffer.slice(0, 1), 1, context.buffer.slice(1), options);
|
|
1104
1067
|
for (const name of optionNames$1) {
|
|
1105
|
-
if (!name.startsWith("--") && !name.startsWith("/") && !name.startsWith("+") && !(name.startsWith("-") && name.length > 2
|
|
1068
|
+
if (!name.startsWith("--") && !name.startsWith("/") && !name.startsWith("+") && !(name.startsWith("-") && name.length > 2)) continue;
|
|
1106
1069
|
const prefix = name.startsWith("/") ? `${name}:` : `${name}=`;
|
|
1107
1070
|
if (context.buffer[0].startsWith(prefix)) {
|
|
1108
1071
|
const value = context.buffer[0].slice(prefix.length);
|
|
@@ -1114,9 +1077,9 @@ function negatableFlag(names, options = {}) {
|
|
|
1114
1077
|
}
|
|
1115
1078
|
}
|
|
1116
1079
|
for (const shortOption of optionNames$1) {
|
|
1117
|
-
if (!shortOption.match(/^-[^-]$/
|
|
1118
|
-
if (!context.buffer[0].startsWith(shortOption)
|
|
1119
|
-
return parseMatchedNegatableFlag(context, shortOption, valueByName.get(shortOption), [context.buffer[0].slice(0,
|
|
1080
|
+
if (!shortOption.match(/^-[^-]$/)) continue;
|
|
1081
|
+
if (!context.buffer[0].startsWith(shortOption)) continue;
|
|
1082
|
+
return parseMatchedNegatableFlag(context, shortOption, valueByName.get(shortOption), [context.buffer[0].slice(0, 2)], 1, [`-${context.buffer[0].slice(2)}`, ...context.buffer.slice(1)], options);
|
|
1120
1083
|
}
|
|
1121
1084
|
const invalidOption = context.buffer[0];
|
|
1122
1085
|
if (options.errors?.noMatch) {
|
|
@@ -1151,7 +1114,7 @@ function negatableFlag(names, options = {}) {
|
|
|
1151
1114
|
const suggestions = [];
|
|
1152
1115
|
if (prefix.startsWith("--") || prefix.startsWith("-") || prefix.startsWith("/") || prefix.startsWith("+")) {
|
|
1153
1116
|
for (const optionName$1 of optionNames$1) if (optionName$1.startsWith(prefix)) {
|
|
1154
|
-
if (prefix === "-" &&
|
|
1117
|
+
if (prefix === "-" && optionName$1.length !== 2) continue;
|
|
1155
1118
|
suggestions.push({
|
|
1156
1119
|
kind: "literal",
|
|
1157
1120
|
text: optionName$1
|
|
@@ -1524,8 +1487,6 @@ function command(name, parser, options = {}) {
|
|
|
1524
1487
|
const isAsync = parser.mode === "async";
|
|
1525
1488
|
const syncInnerParser = parser;
|
|
1526
1489
|
const asyncInnerParser = parser;
|
|
1527
|
-
const commandScope = require_short_option.selectableOptionScope(() => new Set(commandNames));
|
|
1528
|
-
const enteredScope = require_short_option.combinedOptionScope([parser], [name]);
|
|
1529
1490
|
const result = {
|
|
1530
1491
|
[Symbol.for("@optique/core/commandParser")]: true,
|
|
1531
1492
|
mode: parser.mode,
|
|
@@ -1593,7 +1554,6 @@ function command(name, parser, options = {}) {
|
|
|
1593
1554
|
] : baseError
|
|
1594
1555
|
};
|
|
1595
1556
|
}
|
|
1596
|
-
commandScope.select(context, enteredScope);
|
|
1597
1557
|
return {
|
|
1598
1558
|
success: true,
|
|
1599
1559
|
next: {
|
|
@@ -1774,9 +1734,7 @@ function command(name, parser, options = {}) {
|
|
|
1774
1734
|
configurable: true,
|
|
1775
1735
|
enumerable: false
|
|
1776
1736
|
});
|
|
1777
|
-
return require_modifiers.fluent(
|
|
1778
|
-
if (normalizeCommandState(context.state) != null) commandScope.select(context, enteredScope);
|
|
1779
|
-
}));
|
|
1737
|
+
return require_modifiers.fluent(result);
|
|
1780
1738
|
}
|
|
1781
1739
|
/**
|
|
1782
1740
|
* Creates a parser that collects unrecognized options and passes them through.
|