@optique/core 1.0.0-dev.487 → 1.0.0-dev.489
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/doc.cjs +5 -5
- package/dist/doc.js +5 -5
- package/dist/facade.d.cts +2 -0
- package/dist/facade.d.ts +2 -0
- package/dist/parser.cjs +27 -7
- package/dist/parser.js +27 -7
- package/dist/primitives.d.cts +5 -0
- package/dist/primitives.d.ts +5 -0
- package/dist/usage.cjs +7 -3
- package/dist/usage.d.cts +2 -1
- package/dist/usage.d.ts +2 -1
- package/dist/usage.js +7 -3
- package/package.json +1 -1
package/dist/doc.cjs
CHANGED
|
@@ -27,9 +27,10 @@ function scoreSection(section) {
|
|
|
27
27
|
/**
|
|
28
28
|
* The default section comparator: command-only sections come first, then
|
|
29
29
|
* mixed sections, then option/argument-only sections. Untitled sections
|
|
30
|
-
* receive a
|
|
31
|
-
*
|
|
32
|
-
* same score preserve their original relative order
|
|
30
|
+
* receive a score bonus of -1 via {@link scoreSection} so that untitled
|
|
31
|
+
* command-only sections naturally sort before titled command-only sections.
|
|
32
|
+
* Sections with the same score preserve their original relative order
|
|
33
|
+
* (stable sort).
|
|
33
34
|
*/
|
|
34
35
|
function defaultSectionOrder(a, b) {
|
|
35
36
|
return scoreSection(a) - scoreSection(b);
|
|
@@ -103,8 +104,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
103
104
|
})).toSorted((a, b) => {
|
|
104
105
|
const cmp = comparator(a.section, b.section);
|
|
105
106
|
if (cmp !== 0) return cmp;
|
|
106
|
-
|
|
107
|
-
return titleCmp !== 0 ? titleCmp : a.index - b.index;
|
|
107
|
+
return a.index - b.index;
|
|
108
108
|
}).map(({ section }) => section);
|
|
109
109
|
for (const section of sections) {
|
|
110
110
|
if (section.entries.length < 1) continue;
|
package/dist/doc.js
CHANGED
|
@@ -27,9 +27,10 @@ function scoreSection(section) {
|
|
|
27
27
|
/**
|
|
28
28
|
* The default section comparator: command-only sections come first, then
|
|
29
29
|
* mixed sections, then option/argument-only sections. Untitled sections
|
|
30
|
-
* receive a
|
|
31
|
-
*
|
|
32
|
-
* same score preserve their original relative order
|
|
30
|
+
* receive a score bonus of -1 via {@link scoreSection} so that untitled
|
|
31
|
+
* command-only sections naturally sort before titled command-only sections.
|
|
32
|
+
* Sections with the same score preserve their original relative order
|
|
33
|
+
* (stable sort).
|
|
33
34
|
*/
|
|
34
35
|
function defaultSectionOrder(a, b) {
|
|
35
36
|
return scoreSection(a) - scoreSection(b);
|
|
@@ -103,8 +104,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
103
104
|
})).toSorted((a, b) => {
|
|
104
105
|
const cmp = comparator(a.section, b.section);
|
|
105
106
|
if (cmp !== 0) return cmp;
|
|
106
|
-
|
|
107
|
-
return titleCmp !== 0 ? titleCmp : a.index - b.index;
|
|
107
|
+
return a.index - b.index;
|
|
108
108
|
}).map(({ section }) => section);
|
|
109
109
|
for (const section of sections) {
|
|
110
110
|
if (section.entries.length < 1) continue;
|
package/dist/facade.d.cts
CHANGED
|
@@ -32,6 +32,7 @@ interface CommandSubConfig {
|
|
|
32
32
|
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
33
33
|
* - `"usage"`: Hidden from usage lines only.
|
|
34
34
|
* - `"doc"`: Hidden from documentation only.
|
|
35
|
+
* - `"help"`: Hidden from usage and documentation only.
|
|
35
36
|
*/
|
|
36
37
|
readonly hidden?: HiddenVisibility;
|
|
37
38
|
}
|
|
@@ -55,6 +56,7 @@ interface OptionSubConfig {
|
|
|
55
56
|
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
56
57
|
* - `"usage"`: Hidden from usage lines only.
|
|
57
58
|
* - `"doc"`: Hidden from documentation only.
|
|
59
|
+
* - `"help"`: Hidden from usage and documentation only.
|
|
58
60
|
*/
|
|
59
61
|
readonly hidden?: HiddenVisibility;
|
|
60
62
|
}
|
package/dist/facade.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ interface CommandSubConfig {
|
|
|
32
32
|
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
33
33
|
* - `"usage"`: Hidden from usage lines only.
|
|
34
34
|
* - `"doc"`: Hidden from documentation only.
|
|
35
|
+
* - `"help"`: Hidden from usage and documentation only.
|
|
35
36
|
*/
|
|
36
37
|
readonly hidden?: HiddenVisibility;
|
|
37
38
|
}
|
|
@@ -55,6 +56,7 @@ interface OptionSubConfig {
|
|
|
55
56
|
* - `true`: Hidden from usage, documentation, and suggestions.
|
|
56
57
|
* - `"usage"`: Hidden from usage lines only.
|
|
57
58
|
* - `"doc"`: Hidden from documentation only.
|
|
59
|
+
* - `"help"`: Hidden from usage and documentation only.
|
|
58
60
|
*/
|
|
59
61
|
readonly hidden?: HiddenVisibility;
|
|
60
62
|
}
|
package/dist/parser.cjs
CHANGED
|
@@ -387,14 +387,34 @@ function buildDocPage(parser, context, args) {
|
|
|
387
387
|
kind: "available",
|
|
388
388
|
state: context.state
|
|
389
389
|
}, void 0);
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (
|
|
395
|
-
|
|
390
|
+
const buildingSections = [];
|
|
391
|
+
let untitledSection = null;
|
|
392
|
+
const titledSectionMap = /* @__PURE__ */ new Map();
|
|
393
|
+
for (const fragment of fragments) if (fragment.type === "entry") {
|
|
394
|
+
if (untitledSection == null) {
|
|
395
|
+
untitledSection = { entries: [] };
|
|
396
|
+
buildingSections.push(untitledSection);
|
|
397
|
+
}
|
|
398
|
+
untitledSection.entries.push(fragment);
|
|
399
|
+
} else if (fragment.type === "section") if (fragment.title == null) {
|
|
400
|
+
if (untitledSection == null) {
|
|
401
|
+
untitledSection = { entries: [] };
|
|
402
|
+
buildingSections.push(untitledSection);
|
|
403
|
+
}
|
|
404
|
+
untitledSection.entries.push(...fragment.entries);
|
|
405
|
+
} else {
|
|
406
|
+
let section = titledSectionMap.get(fragment.title);
|
|
407
|
+
if (section == null) {
|
|
408
|
+
section = {
|
|
409
|
+
title: fragment.title,
|
|
410
|
+
entries: []
|
|
411
|
+
};
|
|
412
|
+
titledSectionMap.set(fragment.title, section);
|
|
413
|
+
buildingSections.push(section);
|
|
414
|
+
}
|
|
415
|
+
section.entries.push(...fragment.entries);
|
|
396
416
|
}
|
|
397
|
-
|
|
417
|
+
const sections = buildingSections;
|
|
398
418
|
const usage = [...require_usage.normalizeUsage(parser.usage)];
|
|
399
419
|
let i = 0;
|
|
400
420
|
for (const arg of args) {
|
package/dist/parser.js
CHANGED
|
@@ -387,14 +387,34 @@ function buildDocPage(parser, context, args) {
|
|
|
387
387
|
kind: "available",
|
|
388
388
|
state: context.state
|
|
389
389
|
}, void 0);
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (
|
|
395
|
-
|
|
390
|
+
const buildingSections = [];
|
|
391
|
+
let untitledSection = null;
|
|
392
|
+
const titledSectionMap = /* @__PURE__ */ new Map();
|
|
393
|
+
for (const fragment of fragments) if (fragment.type === "entry") {
|
|
394
|
+
if (untitledSection == null) {
|
|
395
|
+
untitledSection = { entries: [] };
|
|
396
|
+
buildingSections.push(untitledSection);
|
|
397
|
+
}
|
|
398
|
+
untitledSection.entries.push(fragment);
|
|
399
|
+
} else if (fragment.type === "section") if (fragment.title == null) {
|
|
400
|
+
if (untitledSection == null) {
|
|
401
|
+
untitledSection = { entries: [] };
|
|
402
|
+
buildingSections.push(untitledSection);
|
|
403
|
+
}
|
|
404
|
+
untitledSection.entries.push(...fragment.entries);
|
|
405
|
+
} else {
|
|
406
|
+
let section = titledSectionMap.get(fragment.title);
|
|
407
|
+
if (section == null) {
|
|
408
|
+
section = {
|
|
409
|
+
title: fragment.title,
|
|
410
|
+
entries: []
|
|
411
|
+
};
|
|
412
|
+
titledSectionMap.set(fragment.title, section);
|
|
413
|
+
buildingSections.push(section);
|
|
414
|
+
}
|
|
415
|
+
section.entries.push(...fragment.entries);
|
|
396
416
|
}
|
|
397
|
-
|
|
417
|
+
const sections = buildingSections;
|
|
398
418
|
const usage = [...normalizeUsage(parser.usage)];
|
|
399
419
|
let i = 0;
|
|
400
420
|
for (const arg of args) {
|
package/dist/primitives.d.cts
CHANGED
|
@@ -52,6 +52,7 @@ interface OptionOptions {
|
|
|
52
52
|
* - `true`: hide from usage, docs, and suggestions
|
|
53
53
|
* - `"usage"`: hide from usage only
|
|
54
54
|
* - `"doc"`: hide from docs only
|
|
55
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
55
56
|
*
|
|
56
57
|
* @since 0.9.0
|
|
57
58
|
*/
|
|
@@ -166,6 +167,7 @@ interface FlagOptions {
|
|
|
166
167
|
* - `true`: hide from usage, docs, and suggestions
|
|
167
168
|
* - `"usage"`: hide from usage only
|
|
168
169
|
* - `"doc"`: hide from docs only
|
|
170
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
169
171
|
*
|
|
170
172
|
* @since 0.9.0
|
|
171
173
|
*/
|
|
@@ -255,6 +257,7 @@ interface ArgumentOptions {
|
|
|
255
257
|
* - `true`: hide from usage, docs, and suggestions
|
|
256
258
|
* - `"usage"`: hide from usage only
|
|
257
259
|
* - `"doc"`: hide from docs only
|
|
260
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
258
261
|
*
|
|
259
262
|
* @since 0.9.0
|
|
260
263
|
*/
|
|
@@ -329,6 +332,7 @@ interface CommandOptions {
|
|
|
329
332
|
* - `true`: hide from usage, docs, and suggestions
|
|
330
333
|
* - `"usage"`: hide from usage only
|
|
331
334
|
* - `"doc"`: hide from docs only
|
|
335
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
332
336
|
*
|
|
333
337
|
* @since 0.9.0
|
|
334
338
|
*/
|
|
@@ -416,6 +420,7 @@ interface PassThroughOptions {
|
|
|
416
420
|
* - `true`: hide from usage, docs, and suggestions
|
|
417
421
|
* - `"usage"`: hide from usage only
|
|
418
422
|
* - `"doc"`: hide from docs only
|
|
423
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
419
424
|
*
|
|
420
425
|
* @since 0.9.0
|
|
421
426
|
*/
|
package/dist/primitives.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ interface OptionOptions {
|
|
|
52
52
|
* - `true`: hide from usage, docs, and suggestions
|
|
53
53
|
* - `"usage"`: hide from usage only
|
|
54
54
|
* - `"doc"`: hide from docs only
|
|
55
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
55
56
|
*
|
|
56
57
|
* @since 0.9.0
|
|
57
58
|
*/
|
|
@@ -166,6 +167,7 @@ interface FlagOptions {
|
|
|
166
167
|
* - `true`: hide from usage, docs, and suggestions
|
|
167
168
|
* - `"usage"`: hide from usage only
|
|
168
169
|
* - `"doc"`: hide from docs only
|
|
170
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
169
171
|
*
|
|
170
172
|
* @since 0.9.0
|
|
171
173
|
*/
|
|
@@ -255,6 +257,7 @@ interface ArgumentOptions {
|
|
|
255
257
|
* - `true`: hide from usage, docs, and suggestions
|
|
256
258
|
* - `"usage"`: hide from usage only
|
|
257
259
|
* - `"doc"`: hide from docs only
|
|
260
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
258
261
|
*
|
|
259
262
|
* @since 0.9.0
|
|
260
263
|
*/
|
|
@@ -329,6 +332,7 @@ interface CommandOptions {
|
|
|
329
332
|
* - `true`: hide from usage, docs, and suggestions
|
|
330
333
|
* - `"usage"`: hide from usage only
|
|
331
334
|
* - `"doc"`: hide from docs only
|
|
335
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
332
336
|
*
|
|
333
337
|
* @since 0.9.0
|
|
334
338
|
*/
|
|
@@ -416,6 +420,7 @@ interface PassThroughOptions {
|
|
|
416
420
|
* - `true`: hide from usage, docs, and suggestions
|
|
417
421
|
* - `"usage"`: hide from usage only
|
|
418
422
|
* - `"doc"`: hide from docs only
|
|
423
|
+
* - `"help"`: hide from usage and docs, keep suggestions
|
|
419
424
|
*
|
|
420
425
|
* @since 0.9.0
|
|
421
426
|
*/
|
package/dist/usage.cjs
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Returns whether the term should be hidden from usage output.
|
|
5
5
|
*/
|
|
6
6
|
function isUsageHidden(hidden) {
|
|
7
|
-
return hidden === true || hidden === "usage";
|
|
7
|
+
return hidden === true || hidden === "usage" || hidden === "help";
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Returns whether the term should be hidden from documentation output.
|
|
11
11
|
*/
|
|
12
12
|
function isDocHidden(hidden) {
|
|
13
|
-
return hidden === true || hidden === "doc";
|
|
13
|
+
return hidden === true || hidden === "doc" || hidden === "help";
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Returns whether the term should be hidden from suggestion/error candidates.
|
|
@@ -25,7 +25,11 @@ function mergeHidden(a, b) {
|
|
|
25
25
|
if (a == null) return b;
|
|
26
26
|
if (b == null) return a;
|
|
27
27
|
if (a === true || b === true) return true;
|
|
28
|
-
if (a
|
|
28
|
+
if (a === false) return b;
|
|
29
|
+
if (b === false) return a;
|
|
30
|
+
if (a === b) return a;
|
|
31
|
+
if (a === "help" || b === "help") return "help";
|
|
32
|
+
if ((a === "usage" || a === "doc") && (b === "usage" || b === "doc")) return "help";
|
|
29
33
|
return a;
|
|
30
34
|
}
|
|
31
35
|
/**
|
package/dist/usage.d.cts
CHANGED
|
@@ -18,8 +18,9 @@ type OptionName = `--${string}` | `-${string}` | `/${string}` | `+${string}`;
|
|
|
18
18
|
* - `true`: hidden from usage, documentation, and suggestions
|
|
19
19
|
* - `"usage"`: hidden from usage only
|
|
20
20
|
* - `"doc"`: hidden from documentation only
|
|
21
|
+
* - `"help"`: hidden from usage and documentation, but shown in suggestions
|
|
21
22
|
*/
|
|
22
|
-
type HiddenVisibility = boolean | "usage" | "doc";
|
|
23
|
+
type HiddenVisibility = boolean | "usage" | "doc" | "help";
|
|
23
24
|
/**
|
|
24
25
|
* Returns whether the term should be hidden from usage output.
|
|
25
26
|
*/
|
package/dist/usage.d.ts
CHANGED
|
@@ -18,8 +18,9 @@ type OptionName = `--${string}` | `-${string}` | `/${string}` | `+${string}`;
|
|
|
18
18
|
* - `true`: hidden from usage, documentation, and suggestions
|
|
19
19
|
* - `"usage"`: hidden from usage only
|
|
20
20
|
* - `"doc"`: hidden from documentation only
|
|
21
|
+
* - `"help"`: hidden from usage and documentation, but shown in suggestions
|
|
21
22
|
*/
|
|
22
|
-
type HiddenVisibility = boolean | "usage" | "doc";
|
|
23
|
+
type HiddenVisibility = boolean | "usage" | "doc" | "help";
|
|
23
24
|
/**
|
|
24
25
|
* Returns whether the term should be hidden from usage output.
|
|
25
26
|
*/
|
package/dist/usage.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Returns whether the term should be hidden from usage output.
|
|
4
4
|
*/
|
|
5
5
|
function isUsageHidden(hidden) {
|
|
6
|
-
return hidden === true || hidden === "usage";
|
|
6
|
+
return hidden === true || hidden === "usage" || hidden === "help";
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Returns whether the term should be hidden from documentation output.
|
|
10
10
|
*/
|
|
11
11
|
function isDocHidden(hidden) {
|
|
12
|
-
return hidden === true || hidden === "doc";
|
|
12
|
+
return hidden === true || hidden === "doc" || hidden === "help";
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Returns whether the term should be hidden from suggestion/error candidates.
|
|
@@ -24,7 +24,11 @@ function mergeHidden(a, b) {
|
|
|
24
24
|
if (a == null) return b;
|
|
25
25
|
if (b == null) return a;
|
|
26
26
|
if (a === true || b === true) return true;
|
|
27
|
-
if (a
|
|
27
|
+
if (a === false) return b;
|
|
28
|
+
if (b === false) return a;
|
|
29
|
+
if (a === b) return a;
|
|
30
|
+
if (a === "help" || b === "help") return "help";
|
|
31
|
+
if ((a === "usage" || a === "doc") && (b === "usage" || b === "doc")) return "help";
|
|
28
32
|
return a;
|
|
29
33
|
}
|
|
30
34
|
/**
|