@trenskow/arguments-parser 0.3.88 → 0.3.90
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 +17 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -219,17 +219,18 @@ const argumentsParser = (
|
|
|
219
219
|
commands[tool]);
|
|
220
220
|
|
|
221
221
|
},
|
|
222
|
-
parameter: async (
|
|
222
|
+
parameter: async ({
|
|
223
223
|
identifier,
|
|
224
224
|
description,
|
|
225
|
-
schema
|
|
226
|
-
|
|
227
|
-
) => {
|
|
225
|
+
schema
|
|
226
|
+
} = {}, command) => {
|
|
228
227
|
|
|
229
228
|
if (typeof identifier !== 'string') {
|
|
230
229
|
throw new Error('Identifier must be a string');
|
|
231
230
|
}
|
|
232
231
|
|
|
232
|
+
description = description || command.description || strings?.commands?.help?.noDescription || 'No description.';
|
|
233
|
+
|
|
233
234
|
helpUsage.push(`${opening}${caseit(identifier, 'kebab')}${closing}`);
|
|
234
235
|
|
|
235
236
|
helpOptions = () => {
|
|
@@ -248,9 +249,17 @@ const argumentsParser = (
|
|
|
248
249
|
|
|
249
250
|
checkHelp();
|
|
250
251
|
|
|
251
|
-
parameters[identifier] =
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
parameters[identifier] = args[0];
|
|
253
|
+
|
|
254
|
+
try {
|
|
255
|
+
if (typeof schema !== 'undefined') {
|
|
256
|
+
parameters[identifier] = await isvalid(
|
|
257
|
+
parameters[identifier],
|
|
258
|
+
schema);
|
|
259
|
+
}
|
|
260
|
+
} catch (error) {
|
|
261
|
+
printHelp(error);
|
|
262
|
+
}
|
|
254
263
|
|
|
255
264
|
return await next(
|
|
256
265
|
identifier,
|
|
@@ -337,7 +346,7 @@ const argumentsParser = (
|
|
|
337
346
|
const keyPathSchema = keyPaths(options.schema).get(keyPath);
|
|
338
347
|
|
|
339
348
|
let optionKeys = [`--${caseit(keyPath, 'kebab')}`];
|
|
340
|
-
let description = [keyPathSchema.description || 'No description'];
|
|
349
|
+
let description = [keyPathSchema.description || strings?.commands?.help?.noDescription || 'No description'];
|
|
341
350
|
|
|
342
351
|
if (shortOptions[keyPath]) {
|
|
343
352
|
optionKeys.push(`-${shortOptions[keyPath]}`);
|