@optique/core 1.1.12 → 1.1.13
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/completion.cjs +1709 -230
- package/dist/completion.js +1709 -230
- package/dist/constructs.cjs +7 -1
- package/dist/constructs.d.cts +2 -0
- package/dist/constructs.d.ts +2 -0
- package/dist/constructs.js +7 -1
- package/dist/internal/joined-file-suggestion.cjs +73 -0
- package/dist/internal/joined-file-suggestion.js +70 -0
- package/dist/internal/parser.d.cts +8 -0
- package/dist/internal/parser.d.ts +8 -0
- package/dist/modifiers.cjs +14 -8
- package/dist/modifiers.js +14 -8
- package/dist/primitives.cjs +19 -22
- package/dist/primitives.js +19 -22
- package/dist/suggestion.cjs +12 -5
- package/dist/suggestion.d.cts +1 -1
- package/dist/suggestion.d.ts +1 -1
- package/dist/suggestion.js +12 -5
- package/dist/valueparser.cjs +2 -1
- package/dist/valueparser.js +2 -1
- package/package.json +2 -2
package/dist/suggestion.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { message, optionName, text } from "./message.js";
|
|
2
2
|
import { extractCommandNames, extractOptionNames, isSuggestionHidden } from "./usage.js";
|
|
3
|
+
import { mergeJoinedFileSuggestions } from "./internal/joined-file-suggestion.js";
|
|
3
4
|
|
|
4
5
|
//#region src/suggestion.ts
|
|
5
6
|
/**
|
|
@@ -257,22 +258,27 @@ function createErrorWithSuggestions(baseError, invalidInput, usage, type = "both
|
|
|
257
258
|
*
|
|
258
259
|
* For literal suggestions, the text itself is used as the key.
|
|
259
260
|
* For file suggestions, a composite key is created from the type,
|
|
260
|
-
* extensions, and
|
|
261
|
+
* extensions, pattern, and insertion prefix.
|
|
261
262
|
*
|
|
262
263
|
* @param suggestion The suggestion to create a key for
|
|
263
264
|
* @returns A string key that uniquely identifies this suggestion
|
|
264
265
|
* @internal
|
|
265
266
|
*/
|
|
266
267
|
function getSuggestionKey(suggestion) {
|
|
267
|
-
if (suggestion.kind === "literal") return suggestion.text
|
|
268
|
-
return `
|
|
268
|
+
if (suggestion.kind === "literal") return `literal:${suggestion.text}`;
|
|
269
|
+
return `file:${JSON.stringify([
|
|
270
|
+
suggestion.type,
|
|
271
|
+
suggestion.extensions?.toSorted().join(",") ?? "",
|
|
272
|
+
suggestion.pattern ?? "",
|
|
273
|
+
suggestion.prefix ?? ""
|
|
274
|
+
])}`;
|
|
269
275
|
}
|
|
270
276
|
/**
|
|
271
277
|
* Removes duplicate suggestions from an array while preserving order.
|
|
272
278
|
*
|
|
273
279
|
* Suggestions are considered duplicates if they have the same key:
|
|
274
280
|
* - Literal suggestions: same text
|
|
275
|
-
* - File suggestions: same type, extensions, and
|
|
281
|
+
* - File suggestions: same type, extensions, pattern, and insertion prefix
|
|
276
282
|
*
|
|
277
283
|
* The first occurrence of each unique suggestion is kept. For file
|
|
278
284
|
* suggestions, `includeHidden` is merged across duplicates: if any
|
|
@@ -305,7 +311,8 @@ function deduplicateSuggestions(suggestions) {
|
|
|
305
311
|
if (existing == null) {
|
|
306
312
|
entries.set(key, suggestion);
|
|
307
313
|
order.push(key);
|
|
308
|
-
} else if (suggestion.kind === "
|
|
314
|
+
} else if (suggestion.kind === "literal" && existing.kind === "literal") mergeJoinedFileSuggestions(existing, suggestion);
|
|
315
|
+
else if (suggestion.kind === "file" && existing.kind === "file" && suggestion.includeHidden === true && existing.includeHidden !== true) entries.set(key, {
|
|
309
316
|
...existing,
|
|
310
317
|
includeHidden: true
|
|
311
318
|
});
|
package/dist/valueparser.cjs
CHANGED
|
@@ -602,7 +602,8 @@ function prefixKeyValueSuggestion(suggestion, prefix, suffix = "") {
|
|
|
602
602
|
const text$1 = `${prefix}${textValue}${suffix}`;
|
|
603
603
|
if (suggestion.kind === "file" && suffix === "") return {
|
|
604
604
|
...suggestion,
|
|
605
|
-
pattern: text$1
|
|
605
|
+
pattern: text$1,
|
|
606
|
+
prefix: `${prefix}${suggestion.prefix ?? ""}`
|
|
606
607
|
};
|
|
607
608
|
return suggestion.description == null ? {
|
|
608
609
|
kind: "literal",
|
package/dist/valueparser.js
CHANGED
|
@@ -602,7 +602,8 @@ function prefixKeyValueSuggestion(suggestion, prefix, suffix = "") {
|
|
|
602
602
|
const text$1 = `${prefix}${textValue}${suffix}`;
|
|
603
603
|
if (suggestion.kind === "file" && suffix === "") return {
|
|
604
604
|
...suggestion,
|
|
605
|
-
pattern: text$1
|
|
605
|
+
pattern: text$1,
|
|
606
|
+
prefix: `${prefix}${suggestion.prefix ?? ""}`
|
|
606
607
|
};
|
|
607
608
|
return suggestion.description == null ? {
|
|
608
609
|
kind: "literal",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
},
|
|
197
197
|
"sideEffects": false,
|
|
198
198
|
"devDependencies": {
|
|
199
|
-
"@optique/env": "1.1.
|
|
199
|
+
"@optique/env": "1.1.13",
|
|
200
200
|
"@types/node": "^24.0.0",
|
|
201
201
|
"fast-check": "^4.7.0",
|
|
202
202
|
"tsdown": "^0.13.0",
|