args-tokens 0.17.0 → 0.17.1
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/lib/index.js
CHANGED
|
@@ -182,7 +182,7 @@ function resolveArgs(args, tokens, { optionGrouping = false, skipPositional = SK
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
function createRequireError(option, schema) {
|
|
185
|
-
const message = schema.type === "positional" ? `Positional argument '${option}' is required` : `
|
|
185
|
+
const message = schema.type === "positional" ? `Positional argument '${option}' is required` : `Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}is required`;
|
|
186
186
|
return new ArgResolveError(message, option, "required", schema);
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
@@ -214,7 +214,7 @@ function validateValue(token, option, schema) {
|
|
|
214
214
|
break;
|
|
215
215
|
}
|
|
216
216
|
case "enum": {
|
|
217
|
-
if (schema.choices && !schema.choices.includes(token.value)) return new ArgResolveError(`
|
|
217
|
+
if (schema.choices && !schema.choices.includes(token.value)) return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be chosen from '${schema.type}' [${schema.choices.map((c) => JSON.stringify(c)).join(", ")}] values`, option, "type", schema);
|
|
218
218
|
break;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
@@ -223,7 +223,7 @@ function isNumeric(str) {
|
|
|
223
223
|
return str.trim() !== "" && !isNaN(str);
|
|
224
224
|
}
|
|
225
225
|
function createTypeError(option, schema) {
|
|
226
|
-
return new ArgResolveError(`
|
|
226
|
+
return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be '${schema.type}'`, option, "type", schema);
|
|
227
227
|
}
|
|
228
228
|
function resolveArgumentValue(token, schema) {
|
|
229
229
|
if (token.value) return schema.type === "number" ? +token.value : token.value;
|
package/lib/resolver.js
CHANGED