@trenskow/arguments-parser 0.2.4 → 0.2.5
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 +19 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -173,6 +173,23 @@ const argumentsParser = ({ args = process.argv.slice(2), argvLevel = 0, placehol
|
|
|
173
173
|
|
|
174
174
|
print();
|
|
175
175
|
|
|
176
|
+
if (error) {
|
|
177
|
+
|
|
178
|
+
print();
|
|
179
|
+
|
|
180
|
+
(error.errors || [error])
|
|
181
|
+
.forEach((error) => {
|
|
182
|
+
if (error.keyPath) {
|
|
183
|
+
print.err(`--${caseit(error.keyPath.join('.'), 'kebab')}: ${error.message}`);
|
|
184
|
+
} else {
|
|
185
|
+
print.err(error.message);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
print();
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
176
193
|
process.exit(error ? 1 : 0);
|
|
177
194
|
|
|
178
195
|
};
|
|
@@ -220,10 +237,10 @@ const argumentsParser = ({ args = process.argv.slice(2), argvLevel = 0, placehol
|
|
|
220
237
|
|
|
221
238
|
try {
|
|
222
239
|
data = await isvalid(data, schema, {
|
|
223
|
-
|
|
240
|
+
aggregatedErrors: 'flatten'
|
|
224
241
|
});
|
|
225
242
|
} catch (error) {
|
|
226
|
-
printHelp(
|
|
243
|
+
printHelp(error);
|
|
227
244
|
}
|
|
228
245
|
|
|
229
246
|
return Object.assign({}, data, {
|