@trenskow/arguments-parser 0.3.89 → 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 +13 -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,10 +249,14 @@ const argumentsParser = (
|
|
|
248
249
|
|
|
249
250
|
checkHelp();
|
|
250
251
|
|
|
252
|
+
parameters[identifier] = args[0];
|
|
253
|
+
|
|
251
254
|
try {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
if (typeof schema !== 'undefined') {
|
|
256
|
+
parameters[identifier] = await isvalid(
|
|
257
|
+
parameters[identifier],
|
|
258
|
+
schema);
|
|
259
|
+
}
|
|
255
260
|
} catch (error) {
|
|
256
261
|
printHelp(error);
|
|
257
262
|
}
|
|
@@ -341,7 +346,7 @@ const argumentsParser = (
|
|
|
341
346
|
const keyPathSchema = keyPaths(options.schema).get(keyPath);
|
|
342
347
|
|
|
343
348
|
let optionKeys = [`--${caseit(keyPath, 'kebab')}`];
|
|
344
|
-
let description = [keyPathSchema.description || 'No description'];
|
|
349
|
+
let description = [keyPathSchema.description || strings?.commands?.help?.noDescription || 'No description'];
|
|
345
350
|
|
|
346
351
|
if (shortOptions[keyPath]) {
|
|
347
352
|
optionKeys.push(`-${shortOptions[keyPath]}`);
|