@optique/core 1.2.0-dev.2298 → 1.2.0-dev.2302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/facade.cjs +47 -8
- package/dist/facade.d.cts +22 -1
- package/dist/facade.d.ts +22 -1
- package/dist/facade.js +47 -8
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/internal/mode-dispatch.cjs +39 -1
- package/dist/internal/mode-dispatch.d.cts +8 -5
- package/dist/internal/mode-dispatch.d.ts +8 -5
- package/dist/internal/mode-dispatch.js +37 -1
- package/dist/valueparser.cjs +208 -0
- package/dist/valueparser.d.cts +83 -1
- package/dist/valueparser.d.ts +83 -1
- package/dist/valueparser.js +208 -2
- package/package.json +2 -2
- package/skills/optique/SKILL.md +33 -5
package/dist/facade.cjs
CHANGED
|
@@ -539,7 +539,8 @@ function getHelpCommandContext(commandPath, args, helpIndex) {
|
|
|
539
539
|
function classifyParseFailure(failure, helpOptionNames, helpCommandNames, versionOptionNames, versionCommandNames, completionOptionNames, completionCommandNames) {
|
|
540
540
|
if (failure.remainingArgs.length < 1) return {
|
|
541
541
|
type: "error",
|
|
542
|
-
error: failure.error
|
|
542
|
+
error: failure.error,
|
|
543
|
+
commandPath: failure.commandPath
|
|
543
544
|
};
|
|
544
545
|
const hasConsumedPrefix = failure.consumedCount > 0;
|
|
545
546
|
const firstArg = failure.remainingArgs[0];
|
|
@@ -571,7 +572,8 @@ function classifyParseFailure(failure, helpOptionNames, helpCommandNames, versio
|
|
|
571
572
|
if (secondArg == null || isCompletionImmediatelyAfter || lastHelpVersion?.index === 1 && lastHelpVersion.kind === "version") return { type: "version" };
|
|
572
573
|
return {
|
|
573
574
|
type: "error",
|
|
574
|
-
error: failure.error
|
|
575
|
+
error: failure.error,
|
|
576
|
+
commandPath: failure.commandPath
|
|
575
577
|
};
|
|
576
578
|
}
|
|
577
579
|
let commandAction;
|
|
@@ -601,7 +603,8 @@ function classifyParseFailure(failure, helpOptionNames, helpCommandNames, versio
|
|
|
601
603
|
};
|
|
602
604
|
return {
|
|
603
605
|
type: "error",
|
|
604
|
-
error: failure.error
|
|
606
|
+
error: failure.error,
|
|
607
|
+
commandPath: failure.commandPath
|
|
605
608
|
};
|
|
606
609
|
}
|
|
607
610
|
/**
|
|
@@ -949,7 +952,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
949
952
|
options = optionsParam ?? {};
|
|
950
953
|
}
|
|
951
954
|
require_validate.validateProgramName(programName);
|
|
952
|
-
const { colors, maxWidth, showDefault, showChoices, sectionOrder, showUsage, aboveError = "usage", onError = () => {
|
|
955
|
+
const { colors, maxWidth, showDefault, showChoices, sectionOrder, showUsage, commandList = "recursive", aboveError = "usage", onError = () => {
|
|
953
956
|
throw new RunParserError("Failed to parse command line arguments.");
|
|
954
957
|
}, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
|
|
955
958
|
const norm = (c) => c === true ? {} : c;
|
|
@@ -1121,7 +1124,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1121
1124
|
const isSubcommandHelp = classified.commands.length > 0;
|
|
1122
1125
|
const isTopLevel = !isSubcommandHelp;
|
|
1123
1126
|
const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
|
|
1124
|
-
const augmentedDoc = {
|
|
1127
|
+
const augmentedDoc = maybeCollapseCommandList({
|
|
1125
1128
|
...doc,
|
|
1126
1129
|
brief: shouldOverride ? brief ?? doc.brief : doc.brief,
|
|
1127
1130
|
description: shouldOverride ? description ?? doc.description : doc.description,
|
|
@@ -1129,7 +1132,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1129
1132
|
author: isTopLevel && !isMetaCommandHelp ? author ?? doc.author : void 0,
|
|
1130
1133
|
bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
|
|
1131
1134
|
footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
|
|
1132
|
-
};
|
|
1135
|
+
}, commandList, isTopLevel);
|
|
1133
1136
|
stdout(require_doc.formatDocPage(programName, augmentedDoc, {
|
|
1134
1137
|
colors,
|
|
1135
1138
|
maxWidth,
|
|
@@ -1190,7 +1193,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1190
1193
|
let effectiveAboveError = currentAboveError;
|
|
1191
1194
|
if (effectiveAboveError === "help") if (doc == null) effectiveAboveError = "usage";
|
|
1192
1195
|
else {
|
|
1193
|
-
const augmentedDoc = {
|
|
1196
|
+
const augmentedDoc = maybeCollapseCommandList({
|
|
1194
1197
|
...doc,
|
|
1195
1198
|
brief: brief ?? doc.brief,
|
|
1196
1199
|
description: description ?? doc.description,
|
|
@@ -1198,7 +1201,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1198
1201
|
author: author ?? doc.author,
|
|
1199
1202
|
bugs: bugs ?? doc.bugs,
|
|
1200
1203
|
footer: footer ?? doc.footer
|
|
1201
|
-
};
|
|
1204
|
+
}, commandList, classified.commandPath.length < 1);
|
|
1202
1205
|
stderr(require_doc.formatDocPage(programName, augmentedDoc, {
|
|
1203
1206
|
colors,
|
|
1204
1207
|
maxWidth,
|
|
@@ -1295,6 +1298,42 @@ function runParserAsync(parser, programName, args, options) {
|
|
|
1295
1298
|
const result = runParser(parser, programName, args, options);
|
|
1296
1299
|
return Promise.resolve(result);
|
|
1297
1300
|
}
|
|
1301
|
+
function maybeCollapseCommandList(doc, commandList, isTopLevel) {
|
|
1302
|
+
if (commandList !== "top-level" || !isTopLevel) return doc;
|
|
1303
|
+
return {
|
|
1304
|
+
...doc,
|
|
1305
|
+
sections: doc.sections.map((section) => ({
|
|
1306
|
+
...section,
|
|
1307
|
+
entries: collapseTopLevelCommandEntries(section.entries)
|
|
1308
|
+
}))
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
function collapseTopLevelCommandEntries(entries) {
|
|
1312
|
+
const collapsed = [];
|
|
1313
|
+
const commandIndexes = /* @__PURE__ */ new Map();
|
|
1314
|
+
for (const entry of entries) {
|
|
1315
|
+
if (entry.term.type !== "command") {
|
|
1316
|
+
collapsed.push(entry);
|
|
1317
|
+
continue;
|
|
1318
|
+
}
|
|
1319
|
+
const topLevelName = getTopLevelCommandName(entry.term.name);
|
|
1320
|
+
const existingIndex = commandIndexes.get(topLevelName);
|
|
1321
|
+
const isTopLevel = entry.term.name === topLevelName;
|
|
1322
|
+
if (existingIndex == null) {
|
|
1323
|
+
commandIndexes.set(topLevelName, collapsed.length);
|
|
1324
|
+
collapsed.push(isTopLevel ? entry : { term: {
|
|
1325
|
+
...entry.term,
|
|
1326
|
+
name: topLevelName
|
|
1327
|
+
} });
|
|
1328
|
+
continue;
|
|
1329
|
+
}
|
|
1330
|
+
if (isTopLevel) collapsed[existingIndex] = entry;
|
|
1331
|
+
}
|
|
1332
|
+
return collapsed;
|
|
1333
|
+
}
|
|
1334
|
+
function getTopLevelCommandName(name) {
|
|
1335
|
+
return name.split(" ", 1)[0] ?? name;
|
|
1336
|
+
}
|
|
1298
1337
|
/**
|
|
1299
1338
|
* An error class used to indicate that the command line arguments
|
|
1300
1339
|
* could not be parsed successfully.
|
package/dist/facade.d.cts
CHANGED
|
@@ -8,6 +8,17 @@ import { Program } from "./program.cjs";
|
|
|
8
8
|
|
|
9
9
|
//#region src/facade.d.ts
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Controls how command lists are rendered in top-level help pages.
|
|
13
|
+
*
|
|
14
|
+
* - `"recursive"`: Shows the full flattened command list, including nested
|
|
15
|
+
* leaf commands such as `remote add`.
|
|
16
|
+
* - `"top-level"`: Shows only first-level command names such as `remote`,
|
|
17
|
+
* letting users drill down with `remote --help`.
|
|
18
|
+
*
|
|
19
|
+
* @since 1.2.0
|
|
20
|
+
*/
|
|
21
|
+
type CommandListMode = "recursive" | "top-level";
|
|
11
22
|
/**
|
|
12
23
|
* Sub-configuration for a meta command's command form.
|
|
13
24
|
*
|
|
@@ -116,6 +127,16 @@ interface RunOptions<THelp, TError> {
|
|
|
116
127
|
* @since 1.2.0
|
|
117
128
|
*/
|
|
118
129
|
readonly showUsage?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* How to render command lists in top-level help pages.
|
|
132
|
+
*
|
|
133
|
+
* Pass `"top-level"` to show only first-level commands in the command menu
|
|
134
|
+
* while keeping nested command help available through `<command> --help`.
|
|
135
|
+
*
|
|
136
|
+
* @default `"recursive"`
|
|
137
|
+
* @since 1.2.0
|
|
138
|
+
*/
|
|
139
|
+
readonly commandList?: CommandListMode;
|
|
119
140
|
/**
|
|
120
141
|
* A custom comparator function to control the order of sections in the
|
|
121
142
|
* help output. When provided, it is used instead of the default smart
|
|
@@ -534,4 +555,4 @@ declare function runWithSync<TParser extends Parser<"sync", unknown, unknown>, T
|
|
|
534
555
|
*/
|
|
535
556
|
declare function runWithAsync<TParser extends Parser<Mode, unknown, unknown>, TContexts extends readonly SourceContext<unknown>[], THelp = void, TError = never>(parser: TParser, programName: string, contexts: TContexts, options: RunWithOptions<THelp, TError> & ContextOptionsParam<TContexts, InferValue<TParser>>): Promise<InferValue<TParser>>;
|
|
536
557
|
//#endregion
|
|
537
|
-
export { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, type SourceContextRequest, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
|
558
|
+
export { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, type SourceContextRequest, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
package/dist/facade.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ import { Program } from "./program.js";
|
|
|
8
8
|
|
|
9
9
|
//#region src/facade.d.ts
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Controls how command lists are rendered in top-level help pages.
|
|
13
|
+
*
|
|
14
|
+
* - `"recursive"`: Shows the full flattened command list, including nested
|
|
15
|
+
* leaf commands such as `remote add`.
|
|
16
|
+
* - `"top-level"`: Shows only first-level command names such as `remote`,
|
|
17
|
+
* letting users drill down with `remote --help`.
|
|
18
|
+
*
|
|
19
|
+
* @since 1.2.0
|
|
20
|
+
*/
|
|
21
|
+
type CommandListMode = "recursive" | "top-level";
|
|
11
22
|
/**
|
|
12
23
|
* Sub-configuration for a meta command's command form.
|
|
13
24
|
*
|
|
@@ -116,6 +127,16 @@ interface RunOptions<THelp, TError> {
|
|
|
116
127
|
* @since 1.2.0
|
|
117
128
|
*/
|
|
118
129
|
readonly showUsage?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* How to render command lists in top-level help pages.
|
|
132
|
+
*
|
|
133
|
+
* Pass `"top-level"` to show only first-level commands in the command menu
|
|
134
|
+
* while keeping nested command help available through `<command> --help`.
|
|
135
|
+
*
|
|
136
|
+
* @default `"recursive"`
|
|
137
|
+
* @since 1.2.0
|
|
138
|
+
*/
|
|
139
|
+
readonly commandList?: CommandListMode;
|
|
119
140
|
/**
|
|
120
141
|
* A custom comparator function to control the order of sections in the
|
|
121
142
|
* help output. When provided, it is used instead of the default smart
|
|
@@ -534,4 +555,4 @@ declare function runWithSync<TParser extends Parser<"sync", unknown, unknown>, T
|
|
|
534
555
|
*/
|
|
535
556
|
declare function runWithAsync<TParser extends Parser<Mode, unknown, unknown>, TContexts extends readonly SourceContext<unknown>[], THelp = void, TError = never>(parser: TParser, programName: string, contexts: TContexts, options: RunWithOptions<THelp, TError> & ContextOptionsParam<TContexts, InferValue<TParser>>): Promise<InferValue<TParser>>;
|
|
536
557
|
//#endregion
|
|
537
|
-
export { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, type SourceContextRequest, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
|
558
|
+
export { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, type ParserValuePlaceholder, RunOptions, RunParserError, RunWithOptions, type SourceContext, type SourceContextRequest, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync };
|
package/dist/facade.js
CHANGED
|
@@ -539,7 +539,8 @@ function getHelpCommandContext(commandPath, args, helpIndex) {
|
|
|
539
539
|
function classifyParseFailure(failure, helpOptionNames, helpCommandNames, versionOptionNames, versionCommandNames, completionOptionNames, completionCommandNames) {
|
|
540
540
|
if (failure.remainingArgs.length < 1) return {
|
|
541
541
|
type: "error",
|
|
542
|
-
error: failure.error
|
|
542
|
+
error: failure.error,
|
|
543
|
+
commandPath: failure.commandPath
|
|
543
544
|
};
|
|
544
545
|
const hasConsumedPrefix = failure.consumedCount > 0;
|
|
545
546
|
const firstArg = failure.remainingArgs[0];
|
|
@@ -571,7 +572,8 @@ function classifyParseFailure(failure, helpOptionNames, helpCommandNames, versio
|
|
|
571
572
|
if (secondArg == null || isCompletionImmediatelyAfter || lastHelpVersion?.index === 1 && lastHelpVersion.kind === "version") return { type: "version" };
|
|
572
573
|
return {
|
|
573
574
|
type: "error",
|
|
574
|
-
error: failure.error
|
|
575
|
+
error: failure.error,
|
|
576
|
+
commandPath: failure.commandPath
|
|
575
577
|
};
|
|
576
578
|
}
|
|
577
579
|
let commandAction;
|
|
@@ -601,7 +603,8 @@ function classifyParseFailure(failure, helpOptionNames, helpCommandNames, versio
|
|
|
601
603
|
};
|
|
602
604
|
return {
|
|
603
605
|
type: "error",
|
|
604
|
-
error: failure.error
|
|
606
|
+
error: failure.error,
|
|
607
|
+
commandPath: failure.commandPath
|
|
605
608
|
};
|
|
606
609
|
}
|
|
607
610
|
/**
|
|
@@ -949,7 +952,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
949
952
|
options = optionsParam ?? {};
|
|
950
953
|
}
|
|
951
954
|
validateProgramName(programName);
|
|
952
|
-
const { colors, maxWidth, showDefault, showChoices, sectionOrder, showUsage, aboveError = "usage", onError = () => {
|
|
955
|
+
const { colors, maxWidth, showDefault, showChoices, sectionOrder, showUsage, commandList = "recursive", aboveError = "usage", onError = () => {
|
|
953
956
|
throw new RunParserError("Failed to parse command line arguments.");
|
|
954
957
|
}, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
|
|
955
958
|
const norm = (c) => c === true ? {} : c;
|
|
@@ -1121,7 +1124,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1121
1124
|
const isSubcommandHelp = classified.commands.length > 0;
|
|
1122
1125
|
const isTopLevel = !isSubcommandHelp;
|
|
1123
1126
|
const shouldOverride = !isMetaCommandHelp && !isSubcommandHelp;
|
|
1124
|
-
const augmentedDoc = {
|
|
1127
|
+
const augmentedDoc = maybeCollapseCommandList({
|
|
1125
1128
|
...doc,
|
|
1126
1129
|
brief: shouldOverride ? brief ?? doc.brief : doc.brief,
|
|
1127
1130
|
description: shouldOverride ? description ?? doc.description : doc.description,
|
|
@@ -1129,7 +1132,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1129
1132
|
author: isTopLevel && !isMetaCommandHelp ? author ?? doc.author : void 0,
|
|
1130
1133
|
bugs: isTopLevel && !isMetaCommandHelp ? bugs ?? doc.bugs : void 0,
|
|
1131
1134
|
footer: shouldOverride ? footer ?? doc.footer : doc.footer ?? footer
|
|
1132
|
-
};
|
|
1135
|
+
}, commandList, isTopLevel);
|
|
1133
1136
|
stdout(formatDocPage(programName, augmentedDoc, {
|
|
1134
1137
|
colors,
|
|
1135
1138
|
maxWidth,
|
|
@@ -1190,7 +1193,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1190
1193
|
let effectiveAboveError = currentAboveError;
|
|
1191
1194
|
if (effectiveAboveError === "help") if (doc == null) effectiveAboveError = "usage";
|
|
1192
1195
|
else {
|
|
1193
|
-
const augmentedDoc = {
|
|
1196
|
+
const augmentedDoc = maybeCollapseCommandList({
|
|
1194
1197
|
...doc,
|
|
1195
1198
|
brief: brief ?? doc.brief,
|
|
1196
1199
|
description: description ?? doc.description,
|
|
@@ -1198,7 +1201,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1198
1201
|
author: author ?? doc.author,
|
|
1199
1202
|
bugs: bugs ?? doc.bugs,
|
|
1200
1203
|
footer: footer ?? doc.footer
|
|
1201
|
-
};
|
|
1204
|
+
}, commandList, classified.commandPath.length < 1);
|
|
1202
1205
|
stderr(formatDocPage(programName, augmentedDoc, {
|
|
1203
1206
|
colors,
|
|
1204
1207
|
maxWidth,
|
|
@@ -1295,6 +1298,42 @@ function runParserAsync(parser, programName, args, options) {
|
|
|
1295
1298
|
const result = runParser(parser, programName, args, options);
|
|
1296
1299
|
return Promise.resolve(result);
|
|
1297
1300
|
}
|
|
1301
|
+
function maybeCollapseCommandList(doc, commandList, isTopLevel) {
|
|
1302
|
+
if (commandList !== "top-level" || !isTopLevel) return doc;
|
|
1303
|
+
return {
|
|
1304
|
+
...doc,
|
|
1305
|
+
sections: doc.sections.map((section) => ({
|
|
1306
|
+
...section,
|
|
1307
|
+
entries: collapseTopLevelCommandEntries(section.entries)
|
|
1308
|
+
}))
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
function collapseTopLevelCommandEntries(entries) {
|
|
1312
|
+
const collapsed = [];
|
|
1313
|
+
const commandIndexes = /* @__PURE__ */ new Map();
|
|
1314
|
+
for (const entry of entries) {
|
|
1315
|
+
if (entry.term.type !== "command") {
|
|
1316
|
+
collapsed.push(entry);
|
|
1317
|
+
continue;
|
|
1318
|
+
}
|
|
1319
|
+
const topLevelName = getTopLevelCommandName(entry.term.name);
|
|
1320
|
+
const existingIndex = commandIndexes.get(topLevelName);
|
|
1321
|
+
const isTopLevel = entry.term.name === topLevelName;
|
|
1322
|
+
if (existingIndex == null) {
|
|
1323
|
+
commandIndexes.set(topLevelName, collapsed.length);
|
|
1324
|
+
collapsed.push(isTopLevel ? entry : { term: {
|
|
1325
|
+
...entry.term,
|
|
1326
|
+
name: topLevelName
|
|
1327
|
+
} });
|
|
1328
|
+
continue;
|
|
1329
|
+
}
|
|
1330
|
+
if (isTopLevel) collapsed[existingIndex] = entry;
|
|
1331
|
+
}
|
|
1332
|
+
return collapsed;
|
|
1333
|
+
}
|
|
1334
|
+
function getTopLevelCommandName(name) {
|
|
1335
|
+
return name.split(" ", 1)[0] ?? name;
|
|
1336
|
+
}
|
|
1298
1337
|
/**
|
|
1299
1338
|
* An error class used to indicate that the command line arguments
|
|
1300
1339
|
* could not be parsed successfully.
|
package/dist/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ exports.RunParserError = require_facade.RunParserError;
|
|
|
17
17
|
exports.WithDefaultError = require_modifiers.WithDefaultError;
|
|
18
18
|
exports.argument = require_primitives.argument;
|
|
19
19
|
exports.bash = require_completion.bash;
|
|
20
|
+
exports.biject = require_valueparser.biject;
|
|
20
21
|
exports.checkBooleanOption = require_valueparser.checkBooleanOption;
|
|
21
22
|
exports.checkEnumOption = require_valueparser.checkEnumOption;
|
|
22
23
|
exports.choice = require_valueparser.choice;
|
|
@@ -121,6 +122,7 @@ exports.suggest = require_internal_parser.suggest;
|
|
|
121
122
|
exports.suggestAsync = require_internal_parser.suggestAsync;
|
|
122
123
|
exports.suggestSync = require_internal_parser.suggestSync;
|
|
123
124
|
exports.text = require_message.text;
|
|
125
|
+
exports.transform = require_valueparser.transform;
|
|
124
126
|
exports.tuple = require_constructs.tuple;
|
|
125
127
|
exports.url = require_valueparser.url;
|
|
126
128
|
exports.uuid = require_valueparser.uuid;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,13 +3,13 @@ import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonemp
|
|
|
3
3
|
import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
|
|
4
4
|
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
|
|
5
5
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.cjs";
|
|
6
|
-
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, url, uuid } from "./valueparser.cjs";
|
|
6
|
+
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
|
|
7
7
|
import { CombineModes, DocState, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.cjs";
|
|
8
8
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
|
|
9
9
|
import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser, MultipleErrorOptions, MultipleOptions, ParserModifiers, WithDefaultError, WithDefaultOptions, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
|
|
10
10
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, SeqOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.cjs";
|
|
11
11
|
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.cjs";
|
|
12
12
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
|
|
13
|
-
import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
13
|
+
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
|
|
14
14
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
15
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, 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
|
@@ -3,13 +3,13 @@ import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonemp
|
|
|
3
3
|
import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
|
|
4
4
|
import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
|
|
5
5
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
|
|
6
|
-
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, url, uuid } from "./valueparser.js";
|
|
6
|
+
import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
7
7
|
import { CombineModes, DocState, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
|
|
8
8
|
import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
9
9
|
import { DeferredValue, DeferredValueOptions, DeferredValueSource, FluentParser, MultipleErrorOptions, MultipleOptions, ParserModifiers, WithDefaultError, WithDefaultOptions, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
10
10
|
import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, SeqOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.js";
|
|
11
11
|
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.js";
|
|
12
12
|
import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
|
|
13
|
-
import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
13
|
+
import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
14
|
import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
15
|
-
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
15
|
+
export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import { bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
|
8
8
|
import { WithDefaultError, deferredValue, fluent, isDeferredValue, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
|
|
9
9
|
import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, seq, tuple } from "./constructs.js";
|
|
10
10
|
import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
|
|
11
|
-
import { checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, url, uuid } from "./valueparser.js";
|
|
11
|
+
import { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
|
|
12
12
|
import { argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
|
|
13
13
|
import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
|
|
14
14
|
|
|
15
|
-
export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
15
|
+
export { DuplicateOptionError, RunParserError, WithDefaultError, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, deferredValue, dependency, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, passThrough, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
|
|
@@ -37,6 +37,42 @@ function mapModeValue(mode, value, mapFn) {
|
|
|
37
37
|
return mapFn(value);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
+
* Maps a value or promise while preserving the declared execution mode.
|
|
41
|
+
*
|
|
42
|
+
* Some internal extension hooks predate `ModeValue` and expose a plain
|
|
43
|
+
* `T | Promise<T>` return type. This helper adapts those hooks back into the
|
|
44
|
+
* mode-dispatch boundary before applying a mapping function.
|
|
45
|
+
*
|
|
46
|
+
* @param mode The execution mode.
|
|
47
|
+
* @param value The value or promise to transform.
|
|
48
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
49
|
+
* @returns The mapped value with correct mode wrapping.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
function mapMaybePromiseByMode(mode, value, mapFn) {
|
|
53
|
+
return mapModeValue(mode, wrapForMode(mode, value), mapFn);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Adapts an iterable or async iterable to the declared execution mode.
|
|
57
|
+
*
|
|
58
|
+
* @param mode The execution mode.
|
|
59
|
+
* @param value The iterable to adapt.
|
|
60
|
+
* @returns The iterable with correct mode wrapping.
|
|
61
|
+
* @throws {TypeError} If a synchronous mode receives an async iterable.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
function wrapIterableForMode(mode, value) {
|
|
65
|
+
return dispatchIterableByMode(mode, () => {
|
|
66
|
+
if (Symbol.asyncIterator in value) throw new TypeError("Synchronous mode cannot wrap AsyncIterable value.");
|
|
67
|
+
return value;
|
|
68
|
+
}, () => {
|
|
69
|
+
if (Symbol.asyncIterator in value) return value;
|
|
70
|
+
return async function* () {
|
|
71
|
+
yield* value;
|
|
72
|
+
}();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
40
76
|
* Dispatches iterable to sync or async implementation based on mode.
|
|
41
77
|
*
|
|
42
78
|
* @param mode The execution mode.
|
|
@@ -54,5 +90,7 @@ function dispatchIterableByMode(mode, syncFn, asyncFn) {
|
|
|
54
90
|
//#endregion
|
|
55
91
|
exports.dispatchByMode = dispatchByMode;
|
|
56
92
|
exports.dispatchIterableByMode = dispatchIterableByMode;
|
|
93
|
+
exports.mapMaybePromiseByMode = mapMaybePromiseByMode;
|
|
57
94
|
exports.mapModeValue = mapModeValue;
|
|
58
|
-
exports.wrapForMode = wrapForMode;
|
|
95
|
+
exports.wrapForMode = wrapForMode;
|
|
96
|
+
exports.wrapIterableForMode = wrapIterableForMode;
|
|
@@ -38,14 +38,17 @@ declare function wrapForMode<M extends Mode, T>(mode: M, value: T | Promise<T>):
|
|
|
38
38
|
*/
|
|
39
39
|
declare function mapModeValue<M extends Mode, T, U>(mode: M, value: ModeValue<M, T>, mapFn: (value: T) => U): ModeValue<M, U>;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Maps a value or promise while preserving the declared execution mode.
|
|
42
|
+
*
|
|
43
|
+
* Some internal extension hooks predate `ModeValue` and expose a plain
|
|
44
|
+
* `T | Promise<T>` return type. This helper adapts those hooks back into the
|
|
45
|
+
* mode-dispatch boundary before applying a mapping function.
|
|
42
46
|
*
|
|
43
47
|
* @param mode The execution mode.
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @returns The
|
|
48
|
+
* @param value The value or promise to transform.
|
|
49
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
50
|
+
* @returns The mapped value with correct mode wrapping.
|
|
47
51
|
* @internal
|
|
48
|
-
* @since 0.10.0
|
|
49
52
|
*/
|
|
50
53
|
//#endregion
|
|
51
54
|
export { dispatchByMode, mapModeValue, wrapForMode };
|
|
@@ -38,14 +38,17 @@ declare function wrapForMode<M extends Mode, T>(mode: M, value: T | Promise<T>):
|
|
|
38
38
|
*/
|
|
39
39
|
declare function mapModeValue<M extends Mode, T, U>(mode: M, value: ModeValue<M, T>, mapFn: (value: T) => U): ModeValue<M, U>;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Maps a value or promise while preserving the declared execution mode.
|
|
42
|
+
*
|
|
43
|
+
* Some internal extension hooks predate `ModeValue` and expose a plain
|
|
44
|
+
* `T | Promise<T>` return type. This helper adapts those hooks back into the
|
|
45
|
+
* mode-dispatch boundary before applying a mapping function.
|
|
42
46
|
*
|
|
43
47
|
* @param mode The execution mode.
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @returns The
|
|
48
|
+
* @param value The value or promise to transform.
|
|
49
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
50
|
+
* @returns The mapped value with correct mode wrapping.
|
|
47
51
|
* @internal
|
|
48
|
-
* @since 0.10.0
|
|
49
52
|
*/
|
|
50
53
|
//#endregion
|
|
51
54
|
export { dispatchByMode, mapModeValue, wrapForMode };
|
|
@@ -36,6 +36,42 @@ function mapModeValue(mode, value, mapFn) {
|
|
|
36
36
|
return mapFn(value);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
+
* Maps a value or promise while preserving the declared execution mode.
|
|
40
|
+
*
|
|
41
|
+
* Some internal extension hooks predate `ModeValue` and expose a plain
|
|
42
|
+
* `T | Promise<T>` return type. This helper adapts those hooks back into the
|
|
43
|
+
* mode-dispatch boundary before applying a mapping function.
|
|
44
|
+
*
|
|
45
|
+
* @param mode The execution mode.
|
|
46
|
+
* @param value The value or promise to transform.
|
|
47
|
+
* @param mapFn Mapping function applied to the unwrapped value.
|
|
48
|
+
* @returns The mapped value with correct mode wrapping.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
function mapMaybePromiseByMode(mode, value, mapFn) {
|
|
52
|
+
return mapModeValue(mode, wrapForMode(mode, value), mapFn);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Adapts an iterable or async iterable to the declared execution mode.
|
|
56
|
+
*
|
|
57
|
+
* @param mode The execution mode.
|
|
58
|
+
* @param value The iterable to adapt.
|
|
59
|
+
* @returns The iterable with correct mode wrapping.
|
|
60
|
+
* @throws {TypeError} If a synchronous mode receives an async iterable.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
function wrapIterableForMode(mode, value) {
|
|
64
|
+
return dispatchIterableByMode(mode, () => {
|
|
65
|
+
if (Symbol.asyncIterator in value) throw new TypeError("Synchronous mode cannot wrap AsyncIterable value.");
|
|
66
|
+
return value;
|
|
67
|
+
}, () => {
|
|
68
|
+
if (Symbol.asyncIterator in value) return value;
|
|
69
|
+
return async function* () {
|
|
70
|
+
yield* value;
|
|
71
|
+
}();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
39
75
|
* Dispatches iterable to sync or async implementation based on mode.
|
|
40
76
|
*
|
|
41
77
|
* @param mode The execution mode.
|
|
@@ -51,4 +87,4 @@ function dispatchIterableByMode(mode, syncFn, asyncFn) {
|
|
|
51
87
|
}
|
|
52
88
|
|
|
53
89
|
//#endregion
|
|
54
|
-
export { dispatchByMode, dispatchIterableByMode, mapModeValue, wrapForMode };
|
|
90
|
+
export { dispatchByMode, dispatchIterableByMode, mapMaybePromiseByMode, mapModeValue, wrapForMode, wrapIterableForMode };
|