@optique/core 1.2.12 → 1.2.14-dev.2950
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 { lineBreak, message, optionName, text, value } 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
|
/**
|
|
@@ -322,22 +323,27 @@ function appendValueHint(base, input, candidates, options) {
|
|
|
322
323
|
*
|
|
323
324
|
* For literal suggestions, the text itself is used as the key.
|
|
324
325
|
* For file suggestions, a composite key is created from the type,
|
|
325
|
-
* extensions, and
|
|
326
|
+
* extensions, pattern, and insertion prefix.
|
|
326
327
|
*
|
|
327
328
|
* @param suggestion The suggestion to create a key for
|
|
328
329
|
* @returns A string key that uniquely identifies this suggestion
|
|
329
330
|
* @internal
|
|
330
331
|
*/
|
|
331
332
|
function getSuggestionKey(suggestion) {
|
|
332
|
-
if (suggestion.kind === "literal") return suggestion.text
|
|
333
|
-
return `
|
|
333
|
+
if (suggestion.kind === "literal") return `literal:${suggestion.text}`;
|
|
334
|
+
return `file:${JSON.stringify([
|
|
335
|
+
suggestion.type,
|
|
336
|
+
suggestion.extensions?.toSorted().join(",") ?? "",
|
|
337
|
+
suggestion.pattern ?? "",
|
|
338
|
+
suggestion.prefix ?? ""
|
|
339
|
+
])}`;
|
|
334
340
|
}
|
|
335
341
|
/**
|
|
336
342
|
* Removes duplicate suggestions from an array while preserving order.
|
|
337
343
|
*
|
|
338
344
|
* Suggestions are considered duplicates if they have the same key:
|
|
339
345
|
* - Literal suggestions: same text
|
|
340
|
-
* - File suggestions: same type, extensions, and
|
|
346
|
+
* - File suggestions: same type, extensions, pattern, and insertion prefix
|
|
341
347
|
*
|
|
342
348
|
* The first occurrence of each unique suggestion is kept. For file
|
|
343
349
|
* suggestions, `includeHidden` is merged across duplicates: if any
|
|
@@ -370,7 +376,8 @@ function deduplicateSuggestions(suggestions) {
|
|
|
370
376
|
if (existing == null) {
|
|
371
377
|
entries.set(key, suggestion);
|
|
372
378
|
order.push(key);
|
|
373
|
-
} else if (suggestion.kind === "
|
|
379
|
+
} else if (suggestion.kind === "literal" && existing.kind === "literal") mergeJoinedFileSuggestions(existing, suggestion);
|
|
380
|
+
else if (suggestion.kind === "file" && existing.kind === "file" && suggestion.includeHidden === true && existing.includeHidden !== true) entries.set(key, {
|
|
374
381
|
...existing,
|
|
375
382
|
includeHidden: true
|
|
376
383
|
});
|
package/dist/valueparser.cjs
CHANGED
|
@@ -895,7 +895,8 @@ function prefixKeyValueSuggestion(suggestion, prefix, suffix = "") {
|
|
|
895
895
|
const text$1 = `${prefix}${textValue}${suffix}`;
|
|
896
896
|
if (suggestion.kind === "file" && suffix === "") return {
|
|
897
897
|
...suggestion,
|
|
898
|
-
pattern: text$1
|
|
898
|
+
pattern: text$1,
|
|
899
|
+
prefix: `${prefix}${suggestion.prefix ?? ""}`
|
|
899
900
|
};
|
|
900
901
|
return suggestion.description == null ? {
|
|
901
902
|
kind: "literal",
|
package/dist/valueparser.js
CHANGED
|
@@ -895,7 +895,8 @@ function prefixKeyValueSuggestion(suggestion, prefix, suffix = "") {
|
|
|
895
895
|
const text$1 = `${prefix}${textValue}${suffix}`;
|
|
896
896
|
if (suggestion.kind === "file" && suffix === "") return {
|
|
897
897
|
...suggestion,
|
|
898
|
-
pattern: text$1
|
|
898
|
+
pattern: text$1,
|
|
899
|
+
prefix: `${prefix}${suggestion.prefix ?? ""}`
|
|
899
900
|
};
|
|
900
901
|
return suggestion.description == null ? {
|
|
901
902
|
kind: "literal",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14-dev.2950",
|
|
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.2.
|
|
224
|
+
"@optique/env": "1.2.14-dev.2950+6fff88ba",
|
|
225
225
|
"@types/node": "^24.0.0",
|
|
226
226
|
"fast-check": "^4.7.0",
|
|
227
227
|
"tsdown": "^0.13.0",
|