@optique/core 1.2.0-dev.2244 → 1.2.0-dev.2246
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/suggestion.cjs +11 -4
- package/dist/suggestion.js +12 -5
- package/dist/valueparser.cjs +263 -257
- package/dist/valueparser.js +265 -259
- package/package.json +2 -2
package/dist/suggestion.cjs
CHANGED
|
@@ -279,11 +279,18 @@ function createErrorWithSuggestions(baseError, invalidInput, usage, type = "both
|
|
|
279
279
|
*/
|
|
280
280
|
function appendValueHint(base, input, candidates, options) {
|
|
281
281
|
const suggestions = findSimilar(input, candidates, options != null ? {
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
maxDistance: options.maxDistance ?? DEFAULT_FIND_SIMILAR_OPTIONS.maxDistance,
|
|
283
|
+
maxDistanceRatio: DEFAULT_FIND_SIMILAR_OPTIONS.maxDistanceRatio,
|
|
284
|
+
maxSuggestions: options.maxSuggestions ?? DEFAULT_FIND_SIMILAR_OPTIONS.maxSuggestions
|
|
284
285
|
} : void 0);
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
if (suggestions.length === 0) return base;
|
|
287
|
+
let suggestionMsg;
|
|
288
|
+
if (suggestions.length === 1) suggestionMsg = require_message.message`Did you mean ${require_message.value(suggestions[0])}?`;
|
|
289
|
+
else {
|
|
290
|
+
const parts = [require_message.text("Did you mean one of these?")];
|
|
291
|
+
for (const suggestion of suggestions) parts.push(require_message.text("\n "), require_message.value(suggestion));
|
|
292
|
+
suggestionMsg = parts;
|
|
293
|
+
}
|
|
287
294
|
return base.length > 0 ? [
|
|
288
295
|
...base,
|
|
289
296
|
require_message.lineBreak(),
|
package/dist/suggestion.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lineBreak, message, optionName, text } from "./message.js";
|
|
1
|
+
import { lineBreak, message, optionName, text, value } from "./message.js";
|
|
2
2
|
import { extractCommandNames, extractOptionNames, isSuggestionHidden } from "./usage.js";
|
|
3
3
|
|
|
4
4
|
//#region src/suggestion.ts
|
|
@@ -279,11 +279,18 @@ function createErrorWithSuggestions(baseError, invalidInput, usage, type = "both
|
|
|
279
279
|
*/
|
|
280
280
|
function appendValueHint(base, input, candidates, options) {
|
|
281
281
|
const suggestions = findSimilar(input, candidates, options != null ? {
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
maxDistance: options.maxDistance ?? DEFAULT_FIND_SIMILAR_OPTIONS.maxDistance,
|
|
283
|
+
maxDistanceRatio: DEFAULT_FIND_SIMILAR_OPTIONS.maxDistanceRatio,
|
|
284
|
+
maxSuggestions: options.maxSuggestions ?? DEFAULT_FIND_SIMILAR_OPTIONS.maxSuggestions
|
|
284
285
|
} : void 0);
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
if (suggestions.length === 0) return base;
|
|
287
|
+
let suggestionMsg;
|
|
288
|
+
if (suggestions.length === 1) suggestionMsg = message`Did you mean ${value(suggestions[0])}?`;
|
|
289
|
+
else {
|
|
290
|
+
const parts = [text("Did you mean one of these?")];
|
|
291
|
+
for (const suggestion of suggestions) parts.push(text("\n "), value(suggestion));
|
|
292
|
+
suggestionMsg = parts;
|
|
293
|
+
}
|
|
287
294
|
return base.length > 0 ? [
|
|
288
295
|
...base,
|
|
289
296
|
lineBreak(),
|