@trenskow/arguments-parser 0.2.3 → 0.2.4
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 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -9,9 +9,20 @@
|
|
|
9
9
|
import { basename } from 'path';
|
|
10
10
|
|
|
11
11
|
import caseit from '@trenskow/caseit';
|
|
12
|
-
import { default as isvalid, keyPaths, formalize } from 'isvalid';
|
|
12
|
+
import { default as isvalid, keyPaths, formalize, plugins } from 'isvalid';
|
|
13
13
|
import print from '@trenskow/print';
|
|
14
14
|
|
|
15
|
+
plugins.use(() => ({
|
|
16
|
+
phase: 'pre',
|
|
17
|
+
supportsType: () => true,
|
|
18
|
+
validatorsForType: () => ({
|
|
19
|
+
description: ['string'],
|
|
20
|
+
defaultDescription: ['string']
|
|
21
|
+
}),
|
|
22
|
+
validate: (data) => data,
|
|
23
|
+
formalize: (schema) => schema
|
|
24
|
+
}));
|
|
25
|
+
|
|
15
26
|
const argumentsParser = ({ args = process.argv.slice(2), argvLevel = 0, placeholder = '<>', command } = {}) => {
|
|
16
27
|
|
|
17
28
|
const [ opening, closing ] = placeholder.split('');
|
|
@@ -95,18 +106,7 @@ const argumentsParser = ({ args = process.argv.slice(2), argvLevel = 0, placehol
|
|
|
95
106
|
|
|
96
107
|
options.command = options.command || command;
|
|
97
108
|
|
|
98
|
-
schema = formalize(schema
|
|
99
|
-
plugins: [() => ({
|
|
100
|
-
phase: 'pre',
|
|
101
|
-
supportsType: () => true,
|
|
102
|
-
validatorsForType: () => ({
|
|
103
|
-
description: ['string'],
|
|
104
|
-
defaultDescription: ['string']
|
|
105
|
-
}),
|
|
106
|
-
validate: (data) => data,
|
|
107
|
-
formalize: (schema) => schema
|
|
108
|
-
})]
|
|
109
|
-
});
|
|
109
|
+
schema = formalize(schema);
|
|
110
110
|
|
|
111
111
|
let nonOptions;
|
|
112
112
|
let nonOptionsIndex = args.indexOf('--');
|