@optique/core 1.0.0-dev.1461 → 1.0.0-dev.1467
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/parser.cjs +3 -3
- package/dist/parser.js +3 -3
- package/dist/usage.cjs +14 -1
- package/dist/usage.js +14 -1
- package/dist/valueparser.cjs +11 -6
- package/dist/valueparser.d.cts +8 -4
- package/dist/valueparser.d.ts +8 -4
- package/dist/valueparser.js +11 -6
- package/package.json +1 -1
package/dist/parser.cjs
CHANGED
|
@@ -414,12 +414,12 @@ function buildDocPage(parser, context, args) {
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
const sections = buildingSections;
|
|
417
|
-
const usage = require_usage.
|
|
417
|
+
const usage = [...require_usage.normalizeUsage(parser.usage)];
|
|
418
418
|
const maybeApplyCommandUsageLine = (term, arg, isLastArg, usageIndex) => {
|
|
419
419
|
if (term?.type !== "command" || term.name !== arg || !isLastArg || term.usageLine == null) return;
|
|
420
420
|
const defaultUsageLine = require_usage.cloneUsage(usage.slice(usageIndex + 1));
|
|
421
421
|
const customUsageLine = typeof term.usageLine === "function" ? term.usageLine(defaultUsageLine) : term.usageLine;
|
|
422
|
-
const normalizedCustomUsageLine = require_usage.
|
|
422
|
+
const normalizedCustomUsageLine = require_usage.normalizeUsage(customUsageLine);
|
|
423
423
|
usage.splice(usageIndex + 1, usage.length - (usageIndex + 1), ...normalizedCustomUsageLine);
|
|
424
424
|
};
|
|
425
425
|
let i = 0;
|
|
@@ -442,7 +442,7 @@ function buildDocPage(parser, context, args) {
|
|
|
442
442
|
if (first.type === "command" && first.usageLine != null) {
|
|
443
443
|
const defaultUsageLine = require_usage.cloneUsage(usage.slice(1));
|
|
444
444
|
const customUsageLine = typeof first.usageLine === "function" ? first.usageLine(defaultUsageLine) : first.usageLine;
|
|
445
|
-
const normalizedCustomUsageLine = require_usage.
|
|
445
|
+
const normalizedCustomUsageLine = require_usage.normalizeUsage(customUsageLine);
|
|
446
446
|
usage.splice(1, usage.length - 1, ...normalizedCustomUsageLine);
|
|
447
447
|
}
|
|
448
448
|
}
|
package/dist/parser.js
CHANGED
|
@@ -414,12 +414,12 @@ function buildDocPage(parser, context, args) {
|
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
const sections = buildingSections;
|
|
417
|
-
const usage =
|
|
417
|
+
const usage = [...normalizeUsage(parser.usage)];
|
|
418
418
|
const maybeApplyCommandUsageLine = (term, arg, isLastArg, usageIndex) => {
|
|
419
419
|
if (term?.type !== "command" || term.name !== arg || !isLastArg || term.usageLine == null) return;
|
|
420
420
|
const defaultUsageLine = cloneUsage(usage.slice(usageIndex + 1));
|
|
421
421
|
const customUsageLine = typeof term.usageLine === "function" ? term.usageLine(defaultUsageLine) : term.usageLine;
|
|
422
|
-
const normalizedCustomUsageLine =
|
|
422
|
+
const normalizedCustomUsageLine = normalizeUsage(customUsageLine);
|
|
423
423
|
usage.splice(usageIndex + 1, usage.length - (usageIndex + 1), ...normalizedCustomUsageLine);
|
|
424
424
|
};
|
|
425
425
|
let i = 0;
|
|
@@ -442,7 +442,7 @@ function buildDocPage(parser, context, args) {
|
|
|
442
442
|
if (first.type === "command" && first.usageLine != null) {
|
|
443
443
|
const defaultUsageLine = cloneUsage(usage.slice(1));
|
|
444
444
|
const customUsageLine = typeof first.usageLine === "function" ? first.usageLine(defaultUsageLine) : first.usageLine;
|
|
445
|
-
const normalizedCustomUsageLine =
|
|
445
|
+
const normalizedCustomUsageLine = normalizeUsage(customUsageLine);
|
|
446
446
|
usage.splice(1, usage.length - 1, ...normalizedCustomUsageLine);
|
|
447
447
|
}
|
|
448
448
|
}
|
package/dist/usage.cjs
CHANGED
|
@@ -246,7 +246,20 @@ function normalizeUsageTerm(term) {
|
|
|
246
246
|
type: "exclusive",
|
|
247
247
|
terms
|
|
248
248
|
};
|
|
249
|
-
} else
|
|
249
|
+
} else {
|
|
250
|
+
if (term.type === "option") return {
|
|
251
|
+
...term,
|
|
252
|
+
names: [...term.names]
|
|
253
|
+
};
|
|
254
|
+
else if (term.type === "command") {
|
|
255
|
+
if (term.usageLine == null || typeof term.usageLine === "function") return { ...term };
|
|
256
|
+
return {
|
|
257
|
+
...term,
|
|
258
|
+
usageLine: cloneUsage(term.usageLine)
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return { ...term };
|
|
262
|
+
}
|
|
250
263
|
}
|
|
251
264
|
function isNonDegenerateTerm(term) {
|
|
252
265
|
if (term.type === "option") return term.names.length > 0;
|
package/dist/usage.js
CHANGED
|
@@ -245,7 +245,20 @@ function normalizeUsageTerm(term) {
|
|
|
245
245
|
type: "exclusive",
|
|
246
246
|
terms
|
|
247
247
|
};
|
|
248
|
-
} else
|
|
248
|
+
} else {
|
|
249
|
+
if (term.type === "option") return {
|
|
250
|
+
...term,
|
|
251
|
+
names: [...term.names]
|
|
252
|
+
};
|
|
253
|
+
else if (term.type === "command") {
|
|
254
|
+
if (term.usageLine == null || typeof term.usageLine === "function") return { ...term };
|
|
255
|
+
return {
|
|
256
|
+
...term,
|
|
257
|
+
usageLine: cloneUsage(term.usageLine)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return { ...term };
|
|
261
|
+
}
|
|
249
262
|
}
|
|
250
263
|
function isNonDegenerateTerm(term) {
|
|
251
264
|
if (term.type === "option") return term.names.length > 0;
|
package/dist/valueparser.cjs
CHANGED
|
@@ -1925,10 +1925,14 @@ function portRange(options) {
|
|
|
1925
1925
|
* Creates a value parser for MAC (Media Access Control) addresses.
|
|
1926
1926
|
*
|
|
1927
1927
|
* Validates MAC-48 addresses (6 octets, 12 hex digits) in various formats:
|
|
1928
|
-
* - Colon-separated: `00:1A:2B:3C:4D:5E`
|
|
1929
|
-
* - Hyphen-separated: `00-1A-2B-3C-4D-5E`
|
|
1930
|
-
* - Dot-separated (Cisco): `001A.2B3C.4D5E`
|
|
1931
|
-
* - No separator: `001A2B3C4D5E`
|
|
1928
|
+
* - Colon-separated: `00:1A:2B:3C:4D:5E` (1–2 hex digits per octet)
|
|
1929
|
+
* - Hyphen-separated: `00-1A-2B-3C-4D-5E` (1–2 hex digits per octet)
|
|
1930
|
+
* - Dot-separated (Cisco): `001A.2B3C.4D5E` (exactly 4 hex digits per group)
|
|
1931
|
+
* - No separator: `001A2B3C4D5E` (exactly 12 hex digits)
|
|
1932
|
+
*
|
|
1933
|
+
* Colon-separated and hyphen-separated formats accept single-digit octets
|
|
1934
|
+
* (e.g., `0:1:2:3:4:5`), which are automatically zero-padded to canonical
|
|
1935
|
+
* two-digit form (e.g., `00:01:02:03:04:05`).
|
|
1932
1936
|
*
|
|
1933
1937
|
* Returns the MAC address as a formatted string according to `case` and
|
|
1934
1938
|
* `outputSeparator` options.
|
|
@@ -1974,8 +1978,8 @@ function macAddress(options) {
|
|
|
1974
1978
|
const caseOption = options?.case ?? "preserve";
|
|
1975
1979
|
const outputSeparator = options?.outputSeparator;
|
|
1976
1980
|
const metavar = options?.metavar ?? "MAC";
|
|
1977
|
-
const colonRegex = /^([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2})$/;
|
|
1978
|
-
const hyphenRegex = /^([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})$/;
|
|
1981
|
+
const colonRegex = /^([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2})$/;
|
|
1982
|
+
const hyphenRegex = /^([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})$/;
|
|
1979
1983
|
const dotRegex = /^([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})$/;
|
|
1980
1984
|
const noneRegex = /^([0-9a-fA-F]{12})$/;
|
|
1981
1985
|
return {
|
|
@@ -2040,6 +2044,7 @@ function macAddress(options) {
|
|
|
2040
2044
|
error: msg
|
|
2041
2045
|
};
|
|
2042
2046
|
}
|
|
2047
|
+
octets = octets.map((o) => o.padStart(2, "0"));
|
|
2043
2048
|
let formattedOctets = octets;
|
|
2044
2049
|
if (caseOption === "upper") formattedOctets = octets.map((octet) => octet.toUpperCase());
|
|
2045
2050
|
else if (caseOption === "lower") formattedOctets = octets.map((octet) => octet.toLowerCase());
|
package/dist/valueparser.d.cts
CHANGED
|
@@ -1507,10 +1507,14 @@ interface MacAddressOptions {
|
|
|
1507
1507
|
* Creates a value parser for MAC (Media Access Control) addresses.
|
|
1508
1508
|
*
|
|
1509
1509
|
* Validates MAC-48 addresses (6 octets, 12 hex digits) in various formats:
|
|
1510
|
-
* - Colon-separated: `00:1A:2B:3C:4D:5E`
|
|
1511
|
-
* - Hyphen-separated: `00-1A-2B-3C-4D-5E`
|
|
1512
|
-
* - Dot-separated (Cisco): `001A.2B3C.4D5E`
|
|
1513
|
-
* - No separator: `001A2B3C4D5E`
|
|
1510
|
+
* - Colon-separated: `00:1A:2B:3C:4D:5E` (1–2 hex digits per octet)
|
|
1511
|
+
* - Hyphen-separated: `00-1A-2B-3C-4D-5E` (1–2 hex digits per octet)
|
|
1512
|
+
* - Dot-separated (Cisco): `001A.2B3C.4D5E` (exactly 4 hex digits per group)
|
|
1513
|
+
* - No separator: `001A2B3C4D5E` (exactly 12 hex digits)
|
|
1514
|
+
*
|
|
1515
|
+
* Colon-separated and hyphen-separated formats accept single-digit octets
|
|
1516
|
+
* (e.g., `0:1:2:3:4:5`), which are automatically zero-padded to canonical
|
|
1517
|
+
* two-digit form (e.g., `00:01:02:03:04:05`).
|
|
1514
1518
|
*
|
|
1515
1519
|
* Returns the MAC address as a formatted string according to `case` and
|
|
1516
1520
|
* `outputSeparator` options.
|
package/dist/valueparser.d.ts
CHANGED
|
@@ -1507,10 +1507,14 @@ interface MacAddressOptions {
|
|
|
1507
1507
|
* Creates a value parser for MAC (Media Access Control) addresses.
|
|
1508
1508
|
*
|
|
1509
1509
|
* Validates MAC-48 addresses (6 octets, 12 hex digits) in various formats:
|
|
1510
|
-
* - Colon-separated: `00:1A:2B:3C:4D:5E`
|
|
1511
|
-
* - Hyphen-separated: `00-1A-2B-3C-4D-5E`
|
|
1512
|
-
* - Dot-separated (Cisco): `001A.2B3C.4D5E`
|
|
1513
|
-
* - No separator: `001A2B3C4D5E`
|
|
1510
|
+
* - Colon-separated: `00:1A:2B:3C:4D:5E` (1–2 hex digits per octet)
|
|
1511
|
+
* - Hyphen-separated: `00-1A-2B-3C-4D-5E` (1–2 hex digits per octet)
|
|
1512
|
+
* - Dot-separated (Cisco): `001A.2B3C.4D5E` (exactly 4 hex digits per group)
|
|
1513
|
+
* - No separator: `001A2B3C4D5E` (exactly 12 hex digits)
|
|
1514
|
+
*
|
|
1515
|
+
* Colon-separated and hyphen-separated formats accept single-digit octets
|
|
1516
|
+
* (e.g., `0:1:2:3:4:5`), which are automatically zero-padded to canonical
|
|
1517
|
+
* two-digit form (e.g., `00:01:02:03:04:05`).
|
|
1514
1518
|
*
|
|
1515
1519
|
* Returns the MAC address as a formatted string according to `case` and
|
|
1516
1520
|
* `outputSeparator` options.
|
package/dist/valueparser.js
CHANGED
|
@@ -1925,10 +1925,14 @@ function portRange(options) {
|
|
|
1925
1925
|
* Creates a value parser for MAC (Media Access Control) addresses.
|
|
1926
1926
|
*
|
|
1927
1927
|
* Validates MAC-48 addresses (6 octets, 12 hex digits) in various formats:
|
|
1928
|
-
* - Colon-separated: `00:1A:2B:3C:4D:5E`
|
|
1929
|
-
* - Hyphen-separated: `00-1A-2B-3C-4D-5E`
|
|
1930
|
-
* - Dot-separated (Cisco): `001A.2B3C.4D5E`
|
|
1931
|
-
* - No separator: `001A2B3C4D5E`
|
|
1928
|
+
* - Colon-separated: `00:1A:2B:3C:4D:5E` (1–2 hex digits per octet)
|
|
1929
|
+
* - Hyphen-separated: `00-1A-2B-3C-4D-5E` (1–2 hex digits per octet)
|
|
1930
|
+
* - Dot-separated (Cisco): `001A.2B3C.4D5E` (exactly 4 hex digits per group)
|
|
1931
|
+
* - No separator: `001A2B3C4D5E` (exactly 12 hex digits)
|
|
1932
|
+
*
|
|
1933
|
+
* Colon-separated and hyphen-separated formats accept single-digit octets
|
|
1934
|
+
* (e.g., `0:1:2:3:4:5`), which are automatically zero-padded to canonical
|
|
1935
|
+
* two-digit form (e.g., `00:01:02:03:04:05`).
|
|
1932
1936
|
*
|
|
1933
1937
|
* Returns the MAC address as a formatted string according to `case` and
|
|
1934
1938
|
* `outputSeparator` options.
|
|
@@ -1974,8 +1978,8 @@ function macAddress(options) {
|
|
|
1974
1978
|
const caseOption = options?.case ?? "preserve";
|
|
1975
1979
|
const outputSeparator = options?.outputSeparator;
|
|
1976
1980
|
const metavar = options?.metavar ?? "MAC";
|
|
1977
|
-
const colonRegex = /^([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2}):([0-9a-fA-F]{2})$/;
|
|
1978
|
-
const hyphenRegex = /^([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})-([0-9a-fA-F]{2})$/;
|
|
1981
|
+
const colonRegex = /^([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2}):([0-9a-fA-F]{1,2})$/;
|
|
1982
|
+
const hyphenRegex = /^([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})-([0-9a-fA-F]{1,2})$/;
|
|
1979
1983
|
const dotRegex = /^([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})\.([0-9a-fA-F]{4})$/;
|
|
1980
1984
|
const noneRegex = /^([0-9a-fA-F]{12})$/;
|
|
1981
1985
|
return {
|
|
@@ -2040,6 +2044,7 @@ function macAddress(options) {
|
|
|
2040
2044
|
error: msg
|
|
2041
2045
|
};
|
|
2042
2046
|
}
|
|
2047
|
+
octets = octets.map((o) => o.padStart(2, "0"));
|
|
2043
2048
|
let formattedOctets = octets;
|
|
2044
2049
|
if (caseOption === "upper") formattedOctets = octets.map((octet) => octet.toUpperCase());
|
|
2045
2050
|
else if (caseOption === "lower") formattedOctets = octets.map((octet) => octet.toLowerCase());
|