@optique/core 1.0.0-dev.1178 → 1.0.0-dev.1197

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.
@@ -47,12 +47,13 @@ function encodeExtensions(extensions) {
47
47
  * Replaces control characters that would corrupt shell completion protocols.
48
48
  * Shell completion formats use tabs as field delimiters and newlines as record
49
49
  * delimiters. Null bytes are used as delimiters in zsh's format.
50
- * @param description The description string to sanitize.
51
- * @returns The sanitized description with control characters replaced by spaces.
50
+ * This is used for both suggestion text and descriptions.
51
+ * @param text The string to sanitize.
52
+ * @returns The sanitized string with control characters replaced by spaces.
52
53
  * @internal
53
54
  */
54
- function sanitizeDescription(description) {
55
- return description.replace(/[\t\n\r\0]/g, " ");
55
+ function sanitizeForTransport(text) {
56
+ return text.replace(/[\t\n\r\0]/g, " ");
56
57
  }
57
58
  /**
58
59
  * The Bash shell completion generator.
@@ -287,7 +288,7 @@ complete -F _${programName} -- ${programName}
287
288
  let i = 0;
288
289
  for (const suggestion of suggestions) {
289
290
  if (i > 0) yield "\n";
290
- if (suggestion.kind === "literal") yield `${suggestion.text}`;
291
+ if (suggestion.kind === "literal") yield sanitizeForTransport(suggestion.text);
291
292
  else {
292
293
  const extensions = encodeExtensions(suggestion.extensions);
293
294
  const hidden = suggestion.includeHidden ? "1" : "0";
@@ -434,12 +435,12 @@ compdef _${programName.replace(/[^a-zA-Z0-9]/g, "_")} ${programName}
434
435
  },
435
436
  *encodeSuggestions(suggestions) {
436
437
  for (const suggestion of suggestions) if (suggestion.kind === "literal") {
437
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
438
- yield `${suggestion.text}\0${description}\0`;
438
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
439
+ yield `${sanitizeForTransport(suggestion.text)}\0${description}\0`;
439
440
  } else {
440
441
  const extensions = encodeExtensions(suggestion.extensions);
441
442
  const hidden = suggestion.includeHidden ? "1" : "0";
442
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
443
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
443
444
  const pattern = encodePattern(suggestion.pattern ?? "");
444
445
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\0${description}\0`;
445
446
  }
@@ -724,12 +725,12 @@ complete -c ${programName} -f -a '(${functionName})'
724
725
  for (const suggestion of suggestions) {
725
726
  if (i > 0) yield "\n";
726
727
  if (suggestion.kind === "literal") {
727
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
728
- yield `${suggestion.text}\t${description}`;
728
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
729
+ yield `${sanitizeForTransport(suggestion.text)}\t${description}`;
729
730
  } else {
730
731
  const extensions = encodeExtensions(suggestion.extensions);
731
732
  const hidden = suggestion.includeHidden ? "1" : "0";
732
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
733
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
733
734
  const pattern = encodePattern(suggestion.pattern ?? "");
734
735
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\t${description}`;
735
736
  }
@@ -1046,12 +1047,12 @@ ${functionName}-external
1046
1047
  for (const suggestion of suggestions) {
1047
1048
  if (i > 0) yield "\n";
1048
1049
  if (suggestion.kind === "literal") {
1049
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
1050
- yield `${suggestion.text}\t${description}`;
1050
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
1051
+ yield `${sanitizeForTransport(suggestion.text)}\t${description}`;
1051
1052
  } else {
1052
1053
  const extensions = encodeExtensions(suggestion.extensions);
1053
1054
  const hidden = suggestion.includeHidden ? "1" : "0";
1054
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
1055
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
1055
1056
  const pattern = encodePattern(suggestion.pattern ?? "");
1056
1057
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\t${description}`;
1057
1058
  }
@@ -1257,12 +1258,13 @@ ${escapedArgs ? ` \$completionArgs += @(${escapedArgs})
1257
1258
  for (const suggestion of suggestions) {
1258
1259
  if (i > 0) yield "\n";
1259
1260
  if (suggestion.kind === "literal") {
1260
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
1261
- yield `${suggestion.text}\t${suggestion.text}\t${description}`;
1261
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
1262
+ const text = sanitizeForTransport(suggestion.text);
1263
+ yield `${text}\t${text}\t${description}`;
1262
1264
  } else {
1263
1265
  const extensions = encodeExtensions(suggestion.extensions);
1264
1266
  const hidden = suggestion.includeHidden ? "1" : "0";
1265
- const description = suggestion.description == null ? "" : sanitizeDescription(require_message.formatMessage(suggestion.description, { colors: false }));
1267
+ const description = suggestion.description == null ? "" : sanitizeForTransport(require_message.formatMessage(suggestion.description, { colors: false }));
1266
1268
  const pattern = encodePattern(suggestion.pattern ?? "");
1267
1269
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\t[file]\t${description}`;
1268
1270
  }
@@ -47,12 +47,13 @@ function encodeExtensions(extensions) {
47
47
  * Replaces control characters that would corrupt shell completion protocols.
48
48
  * Shell completion formats use tabs as field delimiters and newlines as record
49
49
  * delimiters. Null bytes are used as delimiters in zsh's format.
50
- * @param description The description string to sanitize.
51
- * @returns The sanitized description with control characters replaced by spaces.
50
+ * This is used for both suggestion text and descriptions.
51
+ * @param text The string to sanitize.
52
+ * @returns The sanitized string with control characters replaced by spaces.
52
53
  * @internal
53
54
  */
54
- function sanitizeDescription(description) {
55
- return description.replace(/[\t\n\r\0]/g, " ");
55
+ function sanitizeForTransport(text) {
56
+ return text.replace(/[\t\n\r\0]/g, " ");
56
57
  }
57
58
  /**
58
59
  * The Bash shell completion generator.
@@ -287,7 +288,7 @@ complete -F _${programName} -- ${programName}
287
288
  let i = 0;
288
289
  for (const suggestion of suggestions) {
289
290
  if (i > 0) yield "\n";
290
- if (suggestion.kind === "literal") yield `${suggestion.text}`;
291
+ if (suggestion.kind === "literal") yield sanitizeForTransport(suggestion.text);
291
292
  else {
292
293
  const extensions = encodeExtensions(suggestion.extensions);
293
294
  const hidden = suggestion.includeHidden ? "1" : "0";
@@ -434,12 +435,12 @@ compdef _${programName.replace(/[^a-zA-Z0-9]/g, "_")} ${programName}
434
435
  },
435
436
  *encodeSuggestions(suggestions) {
436
437
  for (const suggestion of suggestions) if (suggestion.kind === "literal") {
437
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
438
- yield `${suggestion.text}\0${description}\0`;
438
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
439
+ yield `${sanitizeForTransport(suggestion.text)}\0${description}\0`;
439
440
  } else {
440
441
  const extensions = encodeExtensions(suggestion.extensions);
441
442
  const hidden = suggestion.includeHidden ? "1" : "0";
442
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
443
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
443
444
  const pattern = encodePattern(suggestion.pattern ?? "");
444
445
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\0${description}\0`;
445
446
  }
@@ -724,12 +725,12 @@ complete -c ${programName} -f -a '(${functionName})'
724
725
  for (const suggestion of suggestions) {
725
726
  if (i > 0) yield "\n";
726
727
  if (suggestion.kind === "literal") {
727
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
728
- yield `${suggestion.text}\t${description}`;
728
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
729
+ yield `${sanitizeForTransport(suggestion.text)}\t${description}`;
729
730
  } else {
730
731
  const extensions = encodeExtensions(suggestion.extensions);
731
732
  const hidden = suggestion.includeHidden ? "1" : "0";
732
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
733
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
733
734
  const pattern = encodePattern(suggestion.pattern ?? "");
734
735
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\t${description}`;
735
736
  }
@@ -1046,12 +1047,12 @@ ${functionName}-external
1046
1047
  for (const suggestion of suggestions) {
1047
1048
  if (i > 0) yield "\n";
1048
1049
  if (suggestion.kind === "literal") {
1049
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
1050
- yield `${suggestion.text}\t${description}`;
1050
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
1051
+ yield `${sanitizeForTransport(suggestion.text)}\t${description}`;
1051
1052
  } else {
1052
1053
  const extensions = encodeExtensions(suggestion.extensions);
1053
1054
  const hidden = suggestion.includeHidden ? "1" : "0";
1054
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
1055
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
1055
1056
  const pattern = encodePattern(suggestion.pattern ?? "");
1056
1057
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\t${description}`;
1057
1058
  }
@@ -1257,12 +1258,13 @@ ${escapedArgs ? ` \$completionArgs += @(${escapedArgs})
1257
1258
  for (const suggestion of suggestions) {
1258
1259
  if (i > 0) yield "\n";
1259
1260
  if (suggestion.kind === "literal") {
1260
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
1261
- yield `${suggestion.text}\t${suggestion.text}\t${description}`;
1261
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
1262
+ const text = sanitizeForTransport(suggestion.text);
1263
+ yield `${text}\t${text}\t${description}`;
1262
1264
  } else {
1263
1265
  const extensions = encodeExtensions(suggestion.extensions);
1264
1266
  const hidden = suggestion.includeHidden ? "1" : "0";
1265
- const description = suggestion.description == null ? "" : sanitizeDescription(formatMessage(suggestion.description, { colors: false }));
1267
+ const description = suggestion.description == null ? "" : sanitizeForTransport(formatMessage(suggestion.description, { colors: false }));
1266
1268
  const pattern = encodePattern(suggestion.pattern ?? "");
1267
1269
  yield `__FILE__:${suggestion.type}:${extensions}:${pattern}:${hidden}\t[file]\t${description}`;
1268
1270
  }
package/dist/doc.cjs CHANGED
@@ -47,8 +47,9 @@ function defaultSectionOrder(a, b) {
47
47
  * @param page The documentation page to format
48
48
  * @param options Formatting options to customize the output
49
49
  * @returns A formatted string representation of the documentation page
50
- * @throws {TypeError} If `programName` or any non-empty section's title
51
- * contains a CR or LF character.
50
+ * @throws {TypeError} If `programName` contains a CR or LF character, or if
51
+ * any non-empty section's title is empty, whitespace-only, or contains a CR
52
+ * or LF character.
52
53
  *
53
54
  * @example
54
55
  * ```typescript
@@ -113,7 +114,7 @@ function formatDocPage(programName, page, options = {}) {
113
114
  if (section.entries.length < 1) continue;
114
115
  output += "\n";
115
116
  if (section.title != null) {
116
- if (/[\r\n]/.test(section.title)) throw new TypeError("Section title must not contain newlines.");
117
+ if (section.title.trim() === "" || /[\r\n]/.test(section.title)) throw new TypeError("Section title must not be empty, whitespace-only, or contain newlines.");
117
118
  const sectionLabel = options.colors ? `\x1b[1;2m${section.title}:\x1b[0m\n` : `${section.title}:\n`;
118
119
  output += sectionLabel;
119
120
  }
package/dist/doc.d.cts CHANGED
@@ -263,8 +263,9 @@ interface DocPageFormatOptions {
263
263
  * @param page The documentation page to format
264
264
  * @param options Formatting options to customize the output
265
265
  * @returns A formatted string representation of the documentation page
266
- * @throws {TypeError} If `programName` or any non-empty section's title
267
- * contains a CR or LF character.
266
+ * @throws {TypeError} If `programName` contains a CR or LF character, or if
267
+ * any non-empty section's title is empty, whitespace-only, or contains a CR
268
+ * or LF character.
268
269
  *
269
270
  * @example
270
271
  * ```typescript
package/dist/doc.d.ts CHANGED
@@ -263,8 +263,9 @@ interface DocPageFormatOptions {
263
263
  * @param page The documentation page to format
264
264
  * @param options Formatting options to customize the output
265
265
  * @returns A formatted string representation of the documentation page
266
- * @throws {TypeError} If `programName` or any non-empty section's title
267
- * contains a CR or LF character.
266
+ * @throws {TypeError} If `programName` contains a CR or LF character, or if
267
+ * any non-empty section's title is empty, whitespace-only, or contains a CR
268
+ * or LF character.
268
269
  *
269
270
  * @example
270
271
  * ```typescript
package/dist/doc.js CHANGED
@@ -47,8 +47,9 @@ function defaultSectionOrder(a, b) {
47
47
  * @param page The documentation page to format
48
48
  * @param options Formatting options to customize the output
49
49
  * @returns A formatted string representation of the documentation page
50
- * @throws {TypeError} If `programName` or any non-empty section's title
51
- * contains a CR or LF character.
50
+ * @throws {TypeError} If `programName` contains a CR or LF character, or if
51
+ * any non-empty section's title is empty, whitespace-only, or contains a CR
52
+ * or LF character.
52
53
  *
53
54
  * @example
54
55
  * ```typescript
@@ -113,7 +114,7 @@ function formatDocPage(programName, page, options = {}) {
113
114
  if (section.entries.length < 1) continue;
114
115
  output += "\n";
115
116
  if (section.title != null) {
116
- if (/[\r\n]/.test(section.title)) throw new TypeError("Section title must not contain newlines.");
117
+ if (section.title.trim() === "" || /[\r\n]/.test(section.title)) throw new TypeError("Section title must not be empty, whitespace-only, or contain newlines.");
117
118
  const sectionLabel = options.colors ? `\x1b[1;2m${section.title}:\x1b[0m\n` : `${section.title}:\n`;
118
119
  output += sectionLabel;
119
120
  }
package/dist/index.cjs CHANGED
@@ -19,6 +19,7 @@ exports.WithDefaultError = require_modifiers.WithDefaultError;
19
19
  exports.annotationKey = require_annotations.annotationKey;
20
20
  exports.argument = require_primitives.argument;
21
21
  exports.bash = require_completion.bash;
22
+ exports.checkBooleanOption = require_valueparser.checkBooleanOption;
22
23
  exports.choice = require_valueparser.choice;
23
24
  exports.cidr = require_valueparser.cidr;
24
25
  exports.command = require_primitives.command;
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ 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, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
5
5
  import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, formatDocPage } from "./doc.cjs";
6
- import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.cjs";
6
+ import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.cjs";
7
7
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.cjs";
8
8
  import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
9
9
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.cjs";
@@ -12,4 +12,4 @@ import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, Mode
12
12
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
13
13
  import { ParserValuePlaceholder, SourceContext } from "./context.cjs";
14
14
  import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
15
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
15
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, checkBooleanOption, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ 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, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
5
5
  import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, formatDocPage } from "./doc.js";
6
- import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
6
+ import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
7
7
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
8
8
  import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
9
9
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, PendingDependencySourceState, ResolvedDependency, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
@@ -12,4 +12,4 @@ import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, Mode
12
12
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
13
13
  import { ParserValuePlaceholder, SourceContext } from "./context.js";
14
14
  import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
15
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
15
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, checkBooleanOption, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
package/dist/index.js CHANGED
@@ -7,9 +7,9 @@ import { DuplicateOptionError, concat, conditional, group, longestMatch, merge,
7
7
  import { formatDocPage } from "./doc.js";
8
8
  import { WithDefaultError, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
9
9
  import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
10
- import { choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
10
+ import { checkBooleanOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
11
11
  import { argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
12
12
  import { getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.js";
13
13
  import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
14
14
 
15
- export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, argument, bash, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
15
+ export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, argument, bash, checkBooleanOption, choice, cidr, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
@@ -113,7 +113,7 @@ function choice(choices, options = {}) {
113
113
  }
114
114
  const stringChoices = Object.freeze([...new Set(choices)]);
115
115
  const stringOptions = options;
116
- if (stringOptions.caseInsensitive !== void 0 && typeof stringOptions.caseInsensitive !== "boolean") throw new TypeError(`Expected caseInsensitive to be a boolean, but got ${typeof stringOptions.caseInsensitive}: ${String(stringOptions.caseInsensitive)}.`);
116
+ checkBooleanOption(stringOptions, "caseInsensitive");
117
117
  const caseInsensitive = stringOptions.caseInsensitive ?? false;
118
118
  const normalizedValues = caseInsensitive ? stringChoices.map((v) => v.toLowerCase()) : stringChoices;
119
119
  if (caseInsensitive) {
@@ -159,6 +159,20 @@ function choice(choices, options = {}) {
159
159
  };
160
160
  }
161
161
  /**
162
+ * Validates that an option value, if present, is a boolean.
163
+ * Throws a {@link TypeError} if the value is defined but not a boolean.
164
+ *
165
+ * @template T The type of the options object.
166
+ * @param options The options object to check.
167
+ * @param key The key of the option to validate.
168
+ * @throws {TypeError} If the option value is defined but not a boolean.
169
+ * @since 1.0.0
170
+ */
171
+ function checkBooleanOption(options, key) {
172
+ const value = options?.[key];
173
+ if (value !== void 0 && typeof value !== "boolean") throw new TypeError(`Expected ${String(key)} to be a boolean, but got ${typeof value}: ${String(value)}.`);
174
+ }
175
+ /**
162
176
  * Expands a numeric string in scientific notation (e.g., `"1e+21"`,
163
177
  * `"1.5e-3"`, `".1e-6"`) into plain decimal form for normalization.
164
178
  * Used for both canonical `String(number)` output and user input.
@@ -871,7 +885,7 @@ function uuid(options = {}) {
871
885
  * @since 0.10.0
872
886
  */
873
887
  function port(options) {
874
- if (options?.disallowWellKnown !== void 0 && typeof options.disallowWellKnown !== "boolean") throw new TypeError(`Expected disallowWellKnown to be a boolean, but got ${typeof options.disallowWellKnown}: ${String(options.disallowWellKnown)}.`);
888
+ checkBooleanOption(options, "disallowWellKnown");
875
889
  if (options?.type !== void 0 && options.type !== "number" && options.type !== "bigint") throw new TypeError(`Expected type to be "number" or "bigint", but got: ${String(options.type)}.`);
876
890
  if (options?.type === "bigint") {
877
891
  const metavar$1 = options.metavar ?? "PORT";
@@ -1133,6 +1147,8 @@ function ipv4(options) {
1133
1147
  *
1134
1148
  * @param options - Options for hostname validation.
1135
1149
  * @returns A value parser for hostnames.
1150
+ * @throws {TypeError} If `allowWildcard`, `allowUnderscore`, or
1151
+ * `allowLocalhost` is not a boolean.
1136
1152
  * @throws {RangeError} If `maxLength` is not a positive integer.
1137
1153
  * @since 0.10.0
1138
1154
  *
@@ -1153,6 +1169,9 @@ function ipv4(options) {
1153
1169
  function hostname(options) {
1154
1170
  const metavar = options?.metavar ?? "HOST";
1155
1171
  require_nonempty.ensureNonEmptyString(metavar);
1172
+ checkBooleanOption(options, "allowWildcard");
1173
+ checkBooleanOption(options, "allowUnderscore");
1174
+ checkBooleanOption(options, "allowLocalhost");
1156
1175
  const allowWildcard = options?.allowWildcard ?? false;
1157
1176
  const allowUnderscore = options?.allowUnderscore ?? false;
1158
1177
  const allowLocalhost = options?.allowLocalhost ?? true;
@@ -1614,8 +1633,8 @@ function socketAddress(options) {
1614
1633
  };
1615
1634
  }
1616
1635
  function portRange(options) {
1617
- if (options?.disallowWellKnown !== void 0 && typeof options.disallowWellKnown !== "boolean") throw new TypeError(`Expected disallowWellKnown to be a boolean, but got ${typeof options.disallowWellKnown}: ${String(options.disallowWellKnown)}.`);
1618
- if (options?.allowSingle !== void 0 && typeof options.allowSingle !== "boolean") throw new TypeError(`Expected allowSingle to be a boolean, but got ${typeof options.allowSingle}: ${String(options.allowSingle)}.`);
1636
+ checkBooleanOption(options, "disallowWellKnown");
1637
+ checkBooleanOption(options, "allowSingle");
1619
1638
  if (options?.type !== void 0 && options.type !== "number" && options.type !== "bigint") throw new TypeError(`Expected type to be "number" or "bigint", but got: ${String(options.type)}.`);
1620
1639
  const separator = options?.separator ?? "-";
1621
1640
  if (/\p{Nd}/u.test(separator)) throw new TypeError(`Expected separator to not contain digits, but got: ${JSON.stringify(separator)}.`);
@@ -1868,6 +1887,7 @@ function macAddress(options) {
1868
1887
  * @returns A parser that accepts valid domain names as strings.
1869
1888
  * @throws {RangeError} If `maxLength` is not a positive integer.
1870
1889
  * @throws {RangeError} If `minLabels` is not a positive integer.
1890
+ * @throws {TypeError} If `allowSubdomains` or `lowercase` is not a boolean.
1871
1891
  * @throws {TypeError} If any `allowedTlds` entry is not a string, is empty,
1872
1892
  * contains dots, has leading/trailing whitespace, or is not a valid DNS
1873
1893
  * label.
@@ -1896,6 +1916,8 @@ function macAddress(options) {
1896
1916
  */
1897
1917
  function domain(options) {
1898
1918
  const metavar = options?.metavar ?? "DOMAIN";
1919
+ checkBooleanOption(options, "allowSubdomains");
1920
+ checkBooleanOption(options, "lowercase");
1899
1921
  const allowSubdomains = options?.allowSubdomains ?? true;
1900
1922
  const allowedTlds = options?.allowedTlds != null ? Object.freeze([...options.allowedTlds]) : void 0;
1901
1923
  const labelRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
@@ -2812,6 +2834,7 @@ function cidr(options) {
2812
2834
  }
2813
2835
 
2814
2836
  //#endregion
2837
+ exports.checkBooleanOption = checkBooleanOption;
2815
2838
  exports.choice = choice;
2816
2839
  exports.cidr = cidr;
2817
2840
  exports.domain = domain;
@@ -233,6 +233,17 @@ declare function choice<const T extends string>(choices: readonly T[], options?:
233
233
  * @since 0.9.0
234
234
  */
235
235
  declare function choice<const T extends number>(choices: readonly T[], options?: ChoiceOptionsNumber): ValueParser<"sync", T>;
236
+ /**
237
+ * Validates that an option value, if present, is a boolean.
238
+ * Throws a {@link TypeError} if the value is defined but not a boolean.
239
+ *
240
+ * @template T The type of the options object.
241
+ * @param options The options object to check.
242
+ * @param key The key of the option to validate.
243
+ * @throws {TypeError} If the option value is defined but not a boolean.
244
+ * @since 1.0.0
245
+ */
246
+ declare function checkBooleanOption<T extends object>(options: T | undefined, key: keyof T): void;
236
247
  /**
237
248
  * Creates a {@link ValueParser} for strings.
238
249
  *
@@ -929,6 +940,8 @@ interface HostnameOptions {
929
940
  *
930
941
  * @param options - Options for hostname validation.
931
942
  * @returns A value parser for hostnames.
943
+ * @throws {TypeError} If `allowWildcard`, `allowUnderscore`, or
944
+ * `allowLocalhost` is not a boolean.
932
945
  * @throws {RangeError} If `maxLength` is not a positive integer.
933
946
  * @since 0.10.0
934
947
  *
@@ -1548,6 +1561,7 @@ interface DomainOptions {
1548
1561
  * @returns A parser that accepts valid domain names as strings.
1549
1562
  * @throws {RangeError} If `maxLength` is not a positive integer.
1550
1563
  * @throws {RangeError} If `minLabels` is not a positive integer.
1564
+ * @throws {TypeError} If `allowSubdomains` or `lowercase` is not a boolean.
1551
1565
  * @throws {TypeError} If any `allowedTlds` entry is not a string, is empty,
1552
1566
  * contains dots, has leading/trailing whitespace, or is not a valid DNS
1553
1567
  * label.
@@ -1892,4 +1906,4 @@ interface CidrOptions {
1892
1906
  */
1893
1907
  declare function cidr(options?: CidrOptions): ValueParser<"sync", CidrValue>;
1894
1908
  //#endregion
1895
- export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, cidr, domain, email, ensureNonEmptyString, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid };
1909
+ export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, choice, cidr, domain, email, ensureNonEmptyString, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid };
@@ -233,6 +233,17 @@ declare function choice<const T extends string>(choices: readonly T[], options?:
233
233
  * @since 0.9.0
234
234
  */
235
235
  declare function choice<const T extends number>(choices: readonly T[], options?: ChoiceOptionsNumber): ValueParser<"sync", T>;
236
+ /**
237
+ * Validates that an option value, if present, is a boolean.
238
+ * Throws a {@link TypeError} if the value is defined but not a boolean.
239
+ *
240
+ * @template T The type of the options object.
241
+ * @param options The options object to check.
242
+ * @param key The key of the option to validate.
243
+ * @throws {TypeError} If the option value is defined but not a boolean.
244
+ * @since 1.0.0
245
+ */
246
+ declare function checkBooleanOption<T extends object>(options: T | undefined, key: keyof T): void;
236
247
  /**
237
248
  * Creates a {@link ValueParser} for strings.
238
249
  *
@@ -929,6 +940,8 @@ interface HostnameOptions {
929
940
  *
930
941
  * @param options - Options for hostname validation.
931
942
  * @returns A value parser for hostnames.
943
+ * @throws {TypeError} If `allowWildcard`, `allowUnderscore`, or
944
+ * `allowLocalhost` is not a boolean.
932
945
  * @throws {RangeError} If `maxLength` is not a positive integer.
933
946
  * @since 0.10.0
934
947
  *
@@ -1548,6 +1561,7 @@ interface DomainOptions {
1548
1561
  * @returns A parser that accepts valid domain names as strings.
1549
1562
  * @throws {RangeError} If `maxLength` is not a positive integer.
1550
1563
  * @throws {RangeError} If `minLabels` is not a positive integer.
1564
+ * @throws {TypeError} If `allowSubdomains` or `lowercase` is not a boolean.
1551
1565
  * @throws {TypeError} If any `allowedTlds` entry is not a string, is empty,
1552
1566
  * contains dots, has leading/trailing whitespace, or is not a valid DNS
1553
1567
  * label.
@@ -1892,4 +1906,4 @@ interface CidrOptions {
1892
1906
  */
1893
1907
  declare function cidr(options?: CidrOptions): ValueParser<"sync", CidrValue>;
1894
1908
  //#endregion
1895
- export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, cidr, domain, email, ensureNonEmptyString, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid };
1909
+ export { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, choice, cidr, domain, email, ensureNonEmptyString, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid };
@@ -113,7 +113,7 @@ function choice(choices, options = {}) {
113
113
  }
114
114
  const stringChoices = Object.freeze([...new Set(choices)]);
115
115
  const stringOptions = options;
116
- if (stringOptions.caseInsensitive !== void 0 && typeof stringOptions.caseInsensitive !== "boolean") throw new TypeError(`Expected caseInsensitive to be a boolean, but got ${typeof stringOptions.caseInsensitive}: ${String(stringOptions.caseInsensitive)}.`);
116
+ checkBooleanOption(stringOptions, "caseInsensitive");
117
117
  const caseInsensitive = stringOptions.caseInsensitive ?? false;
118
118
  const normalizedValues = caseInsensitive ? stringChoices.map((v) => v.toLowerCase()) : stringChoices;
119
119
  if (caseInsensitive) {
@@ -159,6 +159,20 @@ function choice(choices, options = {}) {
159
159
  };
160
160
  }
161
161
  /**
162
+ * Validates that an option value, if present, is a boolean.
163
+ * Throws a {@link TypeError} if the value is defined but not a boolean.
164
+ *
165
+ * @template T The type of the options object.
166
+ * @param options The options object to check.
167
+ * @param key The key of the option to validate.
168
+ * @throws {TypeError} If the option value is defined but not a boolean.
169
+ * @since 1.0.0
170
+ */
171
+ function checkBooleanOption(options, key) {
172
+ const value = options?.[key];
173
+ if (value !== void 0 && typeof value !== "boolean") throw new TypeError(`Expected ${String(key)} to be a boolean, but got ${typeof value}: ${String(value)}.`);
174
+ }
175
+ /**
162
176
  * Expands a numeric string in scientific notation (e.g., `"1e+21"`,
163
177
  * `"1.5e-3"`, `".1e-6"`) into plain decimal form for normalization.
164
178
  * Used for both canonical `String(number)` output and user input.
@@ -871,7 +885,7 @@ function uuid(options = {}) {
871
885
  * @since 0.10.0
872
886
  */
873
887
  function port(options) {
874
- if (options?.disallowWellKnown !== void 0 && typeof options.disallowWellKnown !== "boolean") throw new TypeError(`Expected disallowWellKnown to be a boolean, but got ${typeof options.disallowWellKnown}: ${String(options.disallowWellKnown)}.`);
888
+ checkBooleanOption(options, "disallowWellKnown");
875
889
  if (options?.type !== void 0 && options.type !== "number" && options.type !== "bigint") throw new TypeError(`Expected type to be "number" or "bigint", but got: ${String(options.type)}.`);
876
890
  if (options?.type === "bigint") {
877
891
  const metavar$1 = options.metavar ?? "PORT";
@@ -1133,6 +1147,8 @@ function ipv4(options) {
1133
1147
  *
1134
1148
  * @param options - Options for hostname validation.
1135
1149
  * @returns A value parser for hostnames.
1150
+ * @throws {TypeError} If `allowWildcard`, `allowUnderscore`, or
1151
+ * `allowLocalhost` is not a boolean.
1136
1152
  * @throws {RangeError} If `maxLength` is not a positive integer.
1137
1153
  * @since 0.10.0
1138
1154
  *
@@ -1153,6 +1169,9 @@ function ipv4(options) {
1153
1169
  function hostname(options) {
1154
1170
  const metavar = options?.metavar ?? "HOST";
1155
1171
  ensureNonEmptyString(metavar);
1172
+ checkBooleanOption(options, "allowWildcard");
1173
+ checkBooleanOption(options, "allowUnderscore");
1174
+ checkBooleanOption(options, "allowLocalhost");
1156
1175
  const allowWildcard = options?.allowWildcard ?? false;
1157
1176
  const allowUnderscore = options?.allowUnderscore ?? false;
1158
1177
  const allowLocalhost = options?.allowLocalhost ?? true;
@@ -1614,8 +1633,8 @@ function socketAddress(options) {
1614
1633
  };
1615
1634
  }
1616
1635
  function portRange(options) {
1617
- if (options?.disallowWellKnown !== void 0 && typeof options.disallowWellKnown !== "boolean") throw new TypeError(`Expected disallowWellKnown to be a boolean, but got ${typeof options.disallowWellKnown}: ${String(options.disallowWellKnown)}.`);
1618
- if (options?.allowSingle !== void 0 && typeof options.allowSingle !== "boolean") throw new TypeError(`Expected allowSingle to be a boolean, but got ${typeof options.allowSingle}: ${String(options.allowSingle)}.`);
1636
+ checkBooleanOption(options, "disallowWellKnown");
1637
+ checkBooleanOption(options, "allowSingle");
1619
1638
  if (options?.type !== void 0 && options.type !== "number" && options.type !== "bigint") throw new TypeError(`Expected type to be "number" or "bigint", but got: ${String(options.type)}.`);
1620
1639
  const separator = options?.separator ?? "-";
1621
1640
  if (/\p{Nd}/u.test(separator)) throw new TypeError(`Expected separator to not contain digits, but got: ${JSON.stringify(separator)}.`);
@@ -1868,6 +1887,7 @@ function macAddress(options) {
1868
1887
  * @returns A parser that accepts valid domain names as strings.
1869
1888
  * @throws {RangeError} If `maxLength` is not a positive integer.
1870
1889
  * @throws {RangeError} If `minLabels` is not a positive integer.
1890
+ * @throws {TypeError} If `allowSubdomains` or `lowercase` is not a boolean.
1871
1891
  * @throws {TypeError} If any `allowedTlds` entry is not a string, is empty,
1872
1892
  * contains dots, has leading/trailing whitespace, or is not a valid DNS
1873
1893
  * label.
@@ -1896,6 +1916,8 @@ function macAddress(options) {
1896
1916
  */
1897
1917
  function domain(options) {
1898
1918
  const metavar = options?.metavar ?? "DOMAIN";
1919
+ checkBooleanOption(options, "allowSubdomains");
1920
+ checkBooleanOption(options, "lowercase");
1899
1921
  const allowSubdomains = options?.allowSubdomains ?? true;
1900
1922
  const allowedTlds = options?.allowedTlds != null ? Object.freeze([...options.allowedTlds]) : void 0;
1901
1923
  const labelRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
@@ -2812,4 +2834,4 @@ function cidr(options) {
2812
2834
  }
2813
2835
 
2814
2836
  //#endregion
2815
- export { choice, cidr, domain, email, ensureNonEmptyString, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid };
2837
+ export { checkBooleanOption, choice, cidr, domain, email, ensureNonEmptyString, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1178+6b5574a3",
3
+ "version": "1.0.0-dev.1197+8fa87a88",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",