@optique/core 1.3.0-dev.2379 → 1.3.0-dev.2380

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.
@@ -620,71 +620,6 @@ function string(options = {}) {
620
620
  }
621
621
  };
622
622
  }
623
- /**
624
- * Creates a {@link ValueParser} that compiles regular expression sources.
625
- *
626
- * The entire input is treated as the source. Slash-delimited notation such
627
- * as `/pattern/flags` is not interpreted; use {@link RegExpOptions.flags} to
628
- * configure fixed flags for the parser.
629
- *
630
- * **Security note**: Compiling a source does not establish that it is safe to
631
- * execute. Patterns from untrusted input can cause Regular Expression Denial
632
- * of Service (ReDoS) when matched. Limit pattern and subject lengths, execute
633
- * matches in an environment that can be terminated, or use a linear-time
634
- * regular expression engine when accepting untrusted patterns.
635
- *
636
- * @param options Configuration options for the regular expression parser.
637
- * @returns A sync value parser producing JavaScript {@link RegExp} objects.
638
- * @throws {TypeError} If `options.metavar` is an empty string or
639
- * `options.flags` is not a string.
640
- * @throws {SyntaxError} If `options.flags` contains invalid, duplicate, or
641
- * incompatible regular expression flags.
642
- * @since 1.3.0
643
- */
644
- function regExp(options = {}) {
645
- const metavar$1 = options.metavar ?? "REGEXP";
646
- require_nonempty.ensureNonEmptyString(metavar$1);
647
- if (options.flags !== void 0 && typeof options.flags !== "string") throw new TypeError(`Expected flags to be a string, but got ${typeof options.flags}: ${String(options.flags)}.`);
648
- const flags = new RegExp("", options.flags ?? "").flags;
649
- const invalidRegExp = options.errors?.invalidRegExp;
650
- const parseRegExp = (input) => {
651
- try {
652
- return {
653
- success: true,
654
- value: new RegExp(input, flags)
655
- };
656
- } catch (error) {
657
- if (!(error instanceof SyntaxError)) throw error;
658
- return {
659
- success: false,
660
- error: invalidRegExp ? typeof invalidRegExp === "function" ? invalidRegExp(input) : invalidRegExp : require_message.message`Invalid regular expression: ${input}.`
661
- };
662
- }
663
- };
664
- return {
665
- mode: "sync",
666
- metavar: metavar$1,
667
- get placeholder() {
668
- return new RegExp("", flags);
669
- },
670
- parse: parseRegExp,
671
- validate(value) {
672
- if (!(value instanceof RegExp)) return {
673
- success: false,
674
- error: require_message.message`Expected a RegExp value.`
675
- };
676
- return parseRegExp(value.source);
677
- },
678
- normalize(value) {
679
- if (!(value instanceof RegExp)) return value;
680
- const result = parseRegExp(value.source);
681
- return result.success ? result.value : value;
682
- },
683
- format(value) {
684
- return value.source;
685
- }
686
- };
687
- }
688
623
  function keyValue(options = {}) {
689
624
  const separator = options.separator ?? "=";
690
625
  if (typeof separator !== "string") throw new TypeError(`Expected separator to be a string, but got ${typeof separator}: ${String(separator)}.`);
@@ -6693,7 +6628,6 @@ exports.locale = locale;
6693
6628
  exports.macAddress = macAddress;
6694
6629
  exports.port = port;
6695
6630
  exports.portRange = portRange;
6696
- exports.regExp = regExp;
6697
6631
  exports.semVer = semVer;
6698
6632
  exports.socketAddress = socketAddress;
6699
6633
  exports.string = string;
@@ -498,64 +498,6 @@ declare function checkEnumOption<T extends object>(options: T | undefined, key:
498
498
  * `RegExp` instance.
499
499
  */
500
500
  declare function string(options?: StringOptions): ValueParser<"sync", string>;
501
- /**
502
- * Options for creating a {@link regExp} value parser.
503
- *
504
- * @since 1.3.0
505
- */
506
- interface RegExpOptions {
507
- /**
508
- * The metavariable name for this parser. This is used in help messages to
509
- * indicate what kind of value this parser expects.
510
- * @default `"REGEXP"`
511
- * @since 1.3.0
512
- */
513
- readonly metavar?: NonEmptyString;
514
- /**
515
- * Fixed flags used to compile every input source.
516
- * @default `""`
517
- * @since 1.3.0
518
- */
519
- readonly flags?: string;
520
- /**
521
- * Custom error messages for regular expression parsing failures.
522
- * @since 1.3.0
523
- */
524
- readonly errors?: {
525
- /**
526
- * Custom error message when the input is not a valid regular expression
527
- * source. Can be a static message or a function that receives the input.
528
- *
529
- * **Security note**: Successful compilation does not guarantee safe
530
- * execution. Vulnerable patterns can cause catastrophic backtracking when
531
- * later matched against untrusted data.
532
- * @since 1.3.0
533
- */
534
- readonly invalidRegExp?: Message | ((input: string) => Message);
535
- };
536
- }
537
- /**
538
- * Creates a {@link ValueParser} that compiles regular expression sources.
539
- *
540
- * The entire input is treated as the source. Slash-delimited notation such
541
- * as `/pattern/flags` is not interpreted; use {@link RegExpOptions.flags} to
542
- * configure fixed flags for the parser.
543
- *
544
- * **Security note**: Compiling a source does not establish that it is safe to
545
- * execute. Patterns from untrusted input can cause Regular Expression Denial
546
- * of Service (ReDoS) when matched. Limit pattern and subject lengths, execute
547
- * matches in an environment that can be terminated, or use a linear-time
548
- * regular expression engine when accepting untrusted patterns.
549
- *
550
- * @param options Configuration options for the regular expression parser.
551
- * @returns A sync value parser producing JavaScript {@link RegExp} objects.
552
- * @throws {TypeError} If `options.metavar` is an empty string or
553
- * `options.flags` is not a string.
554
- * @throws {SyntaxError} If `options.flags` contains invalid, duplicate, or
555
- * incompatible regular expression flags.
556
- * @since 1.3.0
557
- */
558
- declare function regExp(options?: RegExpOptions): ValueParser<"sync", RegExp>;
559
501
  interface KeyValueOptionsBase {
560
502
  /**
561
503
  * The metavariable name for this parser. Used in help messages to
@@ -3337,4 +3279,4 @@ declare function firstOf<const TParsers extends readonly [ValueParser<"sync", un
3337
3279
  */
3338
3280
  declare function firstOf<const TParsers extends readonly ValueParser<"sync", unknown>[]>(parsers: TParsers, options?: FirstOfOptions): ValueParser<"sync", ValueParserValue<TParsers[number]>>;
3339
3281
  //#endregion
3340
- export { 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, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
3282
+ export { 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, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, 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, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, transform, url, uuid };
@@ -498,64 +498,6 @@ declare function checkEnumOption<T extends object>(options: T | undefined, key:
498
498
  * `RegExp` instance.
499
499
  */
500
500
  declare function string(options?: StringOptions): ValueParser<"sync", string>;
501
- /**
502
- * Options for creating a {@link regExp} value parser.
503
- *
504
- * @since 1.3.0
505
- */
506
- interface RegExpOptions {
507
- /**
508
- * The metavariable name for this parser. This is used in help messages to
509
- * indicate what kind of value this parser expects.
510
- * @default `"REGEXP"`
511
- * @since 1.3.0
512
- */
513
- readonly metavar?: NonEmptyString;
514
- /**
515
- * Fixed flags used to compile every input source.
516
- * @default `""`
517
- * @since 1.3.0
518
- */
519
- readonly flags?: string;
520
- /**
521
- * Custom error messages for regular expression parsing failures.
522
- * @since 1.3.0
523
- */
524
- readonly errors?: {
525
- /**
526
- * Custom error message when the input is not a valid regular expression
527
- * source. Can be a static message or a function that receives the input.
528
- *
529
- * **Security note**: Successful compilation does not guarantee safe
530
- * execution. Vulnerable patterns can cause catastrophic backtracking when
531
- * later matched against untrusted data.
532
- * @since 1.3.0
533
- */
534
- readonly invalidRegExp?: Message | ((input: string) => Message);
535
- };
536
- }
537
- /**
538
- * Creates a {@link ValueParser} that compiles regular expression sources.
539
- *
540
- * The entire input is treated as the source. Slash-delimited notation such
541
- * as `/pattern/flags` is not interpreted; use {@link RegExpOptions.flags} to
542
- * configure fixed flags for the parser.
543
- *
544
- * **Security note**: Compiling a source does not establish that it is safe to
545
- * execute. Patterns from untrusted input can cause Regular Expression Denial
546
- * of Service (ReDoS) when matched. Limit pattern and subject lengths, execute
547
- * matches in an environment that can be terminated, or use a linear-time
548
- * regular expression engine when accepting untrusted patterns.
549
- *
550
- * @param options Configuration options for the regular expression parser.
551
- * @returns A sync value parser producing JavaScript {@link RegExp} objects.
552
- * @throws {TypeError} If `options.metavar` is an empty string or
553
- * `options.flags` is not a string.
554
- * @throws {SyntaxError} If `options.flags` contains invalid, duplicate, or
555
- * incompatible regular expression flags.
556
- * @since 1.3.0
557
- */
558
- declare function regExp(options?: RegExpOptions): ValueParser<"sync", RegExp>;
559
501
  interface KeyValueOptionsBase {
560
502
  /**
561
503
  * The metavariable name for this parser. Used in help messages to
@@ -3337,4 +3279,4 @@ declare function firstOf<const TParsers extends readonly [ValueParser<"sync", un
3337
3279
  */
3338
3280
  declare function firstOf<const TParsers extends readonly ValueParser<"sync", unknown>[]>(parsers: TParsers, options?: FirstOfOptions): ValueParser<"sync", ValueParserValue<TParsers[number]>>;
3339
3281
  //#endregion
3340
- export { 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, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
3282
+ export { 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, type Mode, type ModeIterable, type ModeValue, type NonEmptyString, 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, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, transform, url, uuid };
@@ -620,71 +620,6 @@ function string(options = {}) {
620
620
  }
621
621
  };
622
622
  }
623
- /**
624
- * Creates a {@link ValueParser} that compiles regular expression sources.
625
- *
626
- * The entire input is treated as the source. Slash-delimited notation such
627
- * as `/pattern/flags` is not interpreted; use {@link RegExpOptions.flags} to
628
- * configure fixed flags for the parser.
629
- *
630
- * **Security note**: Compiling a source does not establish that it is safe to
631
- * execute. Patterns from untrusted input can cause Regular Expression Denial
632
- * of Service (ReDoS) when matched. Limit pattern and subject lengths, execute
633
- * matches in an environment that can be terminated, or use a linear-time
634
- * regular expression engine when accepting untrusted patterns.
635
- *
636
- * @param options Configuration options for the regular expression parser.
637
- * @returns A sync value parser producing JavaScript {@link RegExp} objects.
638
- * @throws {TypeError} If `options.metavar` is an empty string or
639
- * `options.flags` is not a string.
640
- * @throws {SyntaxError} If `options.flags` contains invalid, duplicate, or
641
- * incompatible regular expression flags.
642
- * @since 1.3.0
643
- */
644
- function regExp(options = {}) {
645
- const metavar$1 = options.metavar ?? "REGEXP";
646
- ensureNonEmptyString(metavar$1);
647
- if (options.flags !== void 0 && typeof options.flags !== "string") throw new TypeError(`Expected flags to be a string, but got ${typeof options.flags}: ${String(options.flags)}.`);
648
- const flags = new RegExp("", options.flags ?? "").flags;
649
- const invalidRegExp = options.errors?.invalidRegExp;
650
- const parseRegExp = (input) => {
651
- try {
652
- return {
653
- success: true,
654
- value: new RegExp(input, flags)
655
- };
656
- } catch (error) {
657
- if (!(error instanceof SyntaxError)) throw error;
658
- return {
659
- success: false,
660
- error: invalidRegExp ? typeof invalidRegExp === "function" ? invalidRegExp(input) : invalidRegExp : message`Invalid regular expression: ${input}.`
661
- };
662
- }
663
- };
664
- return {
665
- mode: "sync",
666
- metavar: metavar$1,
667
- get placeholder() {
668
- return new RegExp("", flags);
669
- },
670
- parse: parseRegExp,
671
- validate(value) {
672
- if (!(value instanceof RegExp)) return {
673
- success: false,
674
- error: message`Expected a RegExp value.`
675
- };
676
- return parseRegExp(value.source);
677
- },
678
- normalize(value) {
679
- if (!(value instanceof RegExp)) return value;
680
- const result = parseRegExp(value.source);
681
- return result.success ? result.value : value;
682
- },
683
- format(value) {
684
- return value.source;
685
- }
686
- };
687
- }
688
623
  function keyValue(options = {}) {
689
624
  const separator = options.separator ?? "=";
690
625
  if (typeof separator !== "string") throw new TypeError(`Expected separator to be a string, but got ${typeof separator}: ${String(separator)}.`);
@@ -6667,4 +6602,4 @@ function plainObjectsEqual(a, b) {
6667
6602
  }
6668
6603
 
6669
6604
  //#endregion
6670
- export { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid };
6605
+ export { biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, ensureNonEmptyString, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isNonEmptyString, isValueParser, json, keyValue, locale, macAddress, port, portRange, semVer, socketAddress, string, transform, url, uuid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.3.0-dev.2379",
3
+ "version": "1.3.0-dev.2380",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -221,7 +221,7 @@
221
221
  },
222
222
  "sideEffects": false,
223
223
  "devDependencies": {
224
- "@optique/env": "1.3.0-dev.2379+3e20cbf3",
224
+ "@optique/env": "1.3.0-dev.2380+4bce39a7",
225
225
  "@types/node": "^24.0.0",
226
226
  "fast-check": "^4.7.0",
227
227
  "tsdown": "^0.13.0",
@@ -40,12 +40,11 @@ Core rules
40
40
  - Use `message` from *@optique/core/message* for descriptions, help text, and
41
41
  custom errors. Prefer semantic message helpers such as `optionName()` and
42
42
  `metavar()` over string concatenation when naming CLI elements.
43
- - Use value parsers such as `integer()`, `choice()`, `biject()`, `regExp()`,
44
- `url()`, and `uuid()` instead of validating raw strings after parsing. Use
45
- `regExp({ flags })` for user-supplied regular expression sources,
46
- `biject()` for one-to-one string-to-value choices, and `transform()` when
47
- an existing value parser describes the accepted CLI spelling but your app
48
- needs a different result type. Use `path()` from
43
+ - Use value parsers such as `integer()`, `choice()`, `biject()`, `url()`,
44
+ and `uuid()` instead of validating raw strings after parsing. Use
45
+ `biject()` for one-to-one string-to-value choices, and use `transform()`
46
+ when an existing value parser describes the accepted CLI spelling but your
47
+ app needs a different result type. Use `path()` from
49
48
  `@optique/run/valueparser` for file-system paths. Write a custom
50
49
  `{ mode, metavar, parse, format }` value parser only when the catalog does
51
50
  not cover the domain.
@@ -64,9 +63,6 @@ Core rules
64
63
  brief and command or option sections without the `Usage:` synopsis.
65
64
  For deeply nested command trees, add `commandList: "top-level"` when root
66
65
  help should list only first-level command groups.
67
- - Use `termWidth: "auto"` in runner options when descriptions should align
68
- after the widest visible help term. Optique measures terminal display
69
- width after adding built-in help/version/completion entries.
70
66
 
71
67
 
72
68
  Canonical app shape
@@ -100,7 +96,6 @@ const config = run(parser, {
100
96
  brief: message`Process a file.`,
101
97
  completion: "both",
102
98
  showDefault: true,
103
- termWidth: "auto",
104
99
  });
105
100
 
106
101
  console.log(`Processing ${config.input} on port ${config.port}.`);