@oclif/core 2.1.2 → 2.1.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/help/docopts.js +3 -1
- package/lib/parser/parse.js +10 -4
- package/package.json +3 -3
package/lib/help/docopts.js
CHANGED
|
@@ -76,7 +76,9 @@ class DocOpts {
|
|
|
76
76
|
toString() {
|
|
77
77
|
const opts = this.cmd.id === '.' || this.cmd.id === '' ? [] : ['<%= command.id %>'];
|
|
78
78
|
if (this.cmd.args) {
|
|
79
|
-
const a = Object.values((0, util_1.ensureArgObject)(this.cmd.args)).map(arg =>
|
|
79
|
+
const a = Object.values((0, util_1.ensureArgObject)(this.cmd.args)).map(arg => {
|
|
80
|
+
return arg.required ? arg.name.toUpperCase() : `[${arg.name.toUpperCase()}]`;
|
|
81
|
+
}) || [];
|
|
80
82
|
opts.push(...a);
|
|
81
83
|
}
|
|
82
84
|
try {
|
package/lib/parser/parse.js
CHANGED
|
@@ -241,10 +241,14 @@ class Parser {
|
|
|
241
241
|
if (!flag.parse)
|
|
242
242
|
return input;
|
|
243
243
|
try {
|
|
244
|
+
const ctx = this.context;
|
|
245
|
+
ctx.token = token;
|
|
244
246
|
if (flag.type === 'boolean') {
|
|
245
|
-
|
|
247
|
+
const ctx = this.context;
|
|
248
|
+
ctx.token = token;
|
|
249
|
+
return await flag.parse(input, ctx, flag);
|
|
246
250
|
}
|
|
247
|
-
return flag.parse ? await flag.parse(input,
|
|
251
|
+
return flag.parse ? await flag.parse(input, ctx, flag) : input;
|
|
248
252
|
}
|
|
249
253
|
catch (error) {
|
|
250
254
|
error.message = `Parsing --${flag.name} \n\t${error.message}\nSee more help with --help`;
|
|
@@ -260,13 +264,15 @@ class Parser {
|
|
|
260
264
|
const args = {};
|
|
261
265
|
const tokens = this._argTokens;
|
|
262
266
|
let stdinRead = false;
|
|
267
|
+
const ctx = this.context;
|
|
263
268
|
for (const [name, arg] of Object.entries(this.input.args)) {
|
|
264
269
|
const token = tokens.find(t => t.arg === name);
|
|
270
|
+
ctx.token = token;
|
|
265
271
|
if (token) {
|
|
266
272
|
if (arg.options && !arg.options.includes(token.input)) {
|
|
267
273
|
throw new errors_1.ArgInvalidOptionError(arg, token.input);
|
|
268
274
|
}
|
|
269
|
-
const parsed = await arg.parse(token.input,
|
|
275
|
+
const parsed = await arg.parse(token.input, ctx, arg);
|
|
270
276
|
argv.push(parsed);
|
|
271
277
|
args[token.arg] = parsed;
|
|
272
278
|
}
|
|
@@ -274,7 +280,7 @@ class Parser {
|
|
|
274
280
|
let stdin = await readStdin();
|
|
275
281
|
if (stdin) {
|
|
276
282
|
stdin = stdin.trim();
|
|
277
|
-
const parsed = await arg.parse(stdin,
|
|
283
|
+
const parsed = await arg.parse(stdin, ctx, arg);
|
|
278
284
|
argv.push(parsed);
|
|
279
285
|
args[name] = parsed;
|
|
280
286
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/core",
|
|
3
3
|
"description": "base library for oclif CLIs",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.4",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/core/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@commitlint/config-conventional": "^12.1.4",
|
|
39
39
|
"@oclif/plugin-help": "^5.2.4",
|
|
40
|
-
"@oclif/plugin-plugins": "^2.3.
|
|
40
|
+
"@oclif/plugin-plugins": "^2.3.2",
|
|
41
41
|
"@oclif/test": "^2.3.5",
|
|
42
42
|
"@types/ansi-styles": "^3.2.1",
|
|
43
43
|
"@types/chai": "^4.3.4",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"sinon": "^11.1.2",
|
|
76
76
|
"ts-node": "^10.9.1",
|
|
77
77
|
"tsd": "^0.25.0",
|
|
78
|
-
"typescript": "^4.9.
|
|
78
|
+
"typescript": "^4.9.5"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=14.0.0"
|