@optique/core 1.4.0-dev.2671 → 1.4.0-dev.2673
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/valueparser.cjs +13 -2
- package/dist/valueparser.d.cts +2 -2
- package/dist/valueparser.d.ts +2 -2
- package/dist/valueparser.js +13 -2
- package/package.json +2 -2
package/dist/valueparser.cjs
CHANGED
|
@@ -209,7 +209,13 @@ function choice(choices, options = {}) {
|
|
|
209
209
|
placeholder: choices[0],
|
|
210
210
|
choices: stringChoices,
|
|
211
211
|
parse(input) {
|
|
212
|
-
|
|
212
|
+
let inputKey;
|
|
213
|
+
try {
|
|
214
|
+
inputKey = getMatchingKey(input);
|
|
215
|
+
} catch {
|
|
216
|
+
inputKey = void 0;
|
|
217
|
+
}
|
|
218
|
+
const index = inputKey === void 0 ? -1 : matchingKeys.indexOf(inputKey);
|
|
213
219
|
if (index < 0) return {
|
|
214
220
|
success: false,
|
|
215
221
|
error: formatStringChoiceError(input, stringChoices, stringInvalidChoice, snapshotSuggest)
|
|
@@ -223,7 +229,12 @@ function choice(choices, options = {}) {
|
|
|
223
229
|
return String(value);
|
|
224
230
|
},
|
|
225
231
|
suggest(prefix) {
|
|
226
|
-
|
|
232
|
+
let matchingPrefix;
|
|
233
|
+
try {
|
|
234
|
+
matchingPrefix = getMatchingKey(prefix);
|
|
235
|
+
} catch {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
227
238
|
return stringChoices.filter((_value, index) => matchingKeys[index].startsWith(matchingPrefix)).map((value) => ({
|
|
228
239
|
kind: "literal",
|
|
229
240
|
text: value
|
package/dist/valueparser.d.cts
CHANGED
|
@@ -394,8 +394,8 @@ declare function isValueParser<M extends Mode, T>(object: unknown): object is Va
|
|
|
394
394
|
* @throws {TypeError} If `caseInsensitive` is `true` and multiple choices
|
|
395
395
|
* normalize to the same lowercase value.
|
|
396
396
|
* @throws {TypeError} If `key` is not a function, is combined with
|
|
397
|
-
* `caseInsensitive`, returns a non-string key
|
|
398
|
-
* choices the same key.
|
|
397
|
+
* `caseInsensitive`, returns a non-string key for a declared choice,
|
|
398
|
+
* or gives distinct choices the same key.
|
|
399
399
|
*/
|
|
400
400
|
declare function choice<const T extends string>(choices: readonly T[], options?: ChoiceOptionsString): ValueParser<"sync", T>;
|
|
401
401
|
/**
|
package/dist/valueparser.d.ts
CHANGED
|
@@ -394,8 +394,8 @@ declare function isValueParser<M extends Mode, T>(object: unknown): object is Va
|
|
|
394
394
|
* @throws {TypeError} If `caseInsensitive` is `true` and multiple choices
|
|
395
395
|
* normalize to the same lowercase value.
|
|
396
396
|
* @throws {TypeError} If `key` is not a function, is combined with
|
|
397
|
-
* `caseInsensitive`, returns a non-string key
|
|
398
|
-
* choices the same key.
|
|
397
|
+
* `caseInsensitive`, returns a non-string key for a declared choice,
|
|
398
|
+
* or gives distinct choices the same key.
|
|
399
399
|
*/
|
|
400
400
|
declare function choice<const T extends string>(choices: readonly T[], options?: ChoiceOptionsString): ValueParser<"sync", T>;
|
|
401
401
|
/**
|
package/dist/valueparser.js
CHANGED
|
@@ -209,7 +209,13 @@ function choice(choices, options = {}) {
|
|
|
209
209
|
placeholder: choices[0],
|
|
210
210
|
choices: stringChoices,
|
|
211
211
|
parse(input) {
|
|
212
|
-
|
|
212
|
+
let inputKey;
|
|
213
|
+
try {
|
|
214
|
+
inputKey = getMatchingKey(input);
|
|
215
|
+
} catch {
|
|
216
|
+
inputKey = void 0;
|
|
217
|
+
}
|
|
218
|
+
const index = inputKey === void 0 ? -1 : matchingKeys.indexOf(inputKey);
|
|
213
219
|
if (index < 0) return {
|
|
214
220
|
success: false,
|
|
215
221
|
error: formatStringChoiceError(input, stringChoices, stringInvalidChoice, snapshotSuggest)
|
|
@@ -223,7 +229,12 @@ function choice(choices, options = {}) {
|
|
|
223
229
|
return String(value);
|
|
224
230
|
},
|
|
225
231
|
suggest(prefix) {
|
|
226
|
-
|
|
232
|
+
let matchingPrefix;
|
|
233
|
+
try {
|
|
234
|
+
matchingPrefix = getMatchingKey(prefix);
|
|
235
|
+
} catch {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
227
238
|
return stringChoices.filter((_value, index) => matchingKeys[index].startsWith(matchingPrefix)).map((value) => ({
|
|
228
239
|
kind: "literal",
|
|
229
240
|
text: value
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.4.0-dev.
|
|
3
|
+
"version": "1.4.0-dev.2673",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
},
|
|
238
238
|
"sideEffects": false,
|
|
239
239
|
"devDependencies": {
|
|
240
|
-
"@optique/env": "1.4.0-dev.
|
|
240
|
+
"@optique/env": "1.4.0-dev.2673+f2b98759",
|
|
241
241
|
"@types/node": "^24.0.0",
|
|
242
242
|
"fast-check": "^4.7.0",
|
|
243
243
|
"tsdown": "^0.13.0",
|