@vexify-org/yaggs 6.0.0 → 6.1.0
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/parser.js +13 -0
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -41,6 +41,7 @@ class ArgumentParser {
|
|
|
41
41
|
hidden: config.hidden || false,
|
|
42
42
|
conflicts: config.conflicts || [],
|
|
43
43
|
implies: config.implies || {},
|
|
44
|
+
global: config.global !== undefined ? config.global : true,
|
|
44
45
|
...config
|
|
45
46
|
};
|
|
46
47
|
|
|
@@ -413,6 +414,18 @@ class ArgumentParser {
|
|
|
413
414
|
this._handleError(`Not a directory: ${fullPath}`);
|
|
414
415
|
}
|
|
415
416
|
result[name] = fullPath;
|
|
417
|
+
} else if (opt.type === 'date') {
|
|
418
|
+
const date = new Date(value);
|
|
419
|
+
if (isNaN(date.getTime())) {
|
|
420
|
+
this._handleError(`Invalid date for option '${name}'`);
|
|
421
|
+
}
|
|
422
|
+
result[name] = date;
|
|
423
|
+
} else if (opt.type === 'regex') {
|
|
424
|
+
try {
|
|
425
|
+
result[name] = new RegExp(value);
|
|
426
|
+
} catch {
|
|
427
|
+
this._handleError(`Invalid regex for option '${name}'`);
|
|
428
|
+
}
|
|
416
429
|
} else if (opt.type === 'custom' && opt._customType) {
|
|
417
430
|
result[name] = opt._customType(value);
|
|
418
431
|
}
|