@oclif/core 2.0.6 → 2.0.8

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/index.js CHANGED
@@ -88,7 +88,7 @@ class Help extends HelpBase {
88
88
  }
89
89
  const command = this.config.findCommand(subject);
90
90
  if (command) {
91
- if (command.hasDynamicHelp) {
91
+ if (command.hasDynamicHelp && command.pluginType !== 'jit') {
92
92
  const dynamicCommand = await (0, config_1.toCached)(await command.load());
93
93
  await this.showCommandHelp(dynamicCommand);
94
94
  }
@@ -174,8 +174,14 @@ export type OptionFlagProps = FlagProps & {
174
174
  options?: string[];
175
175
  multiple?: boolean;
176
176
  };
177
- export type FlagParser<T, I extends string | boolean, P = CustomOptions> = (input: I, context: Command, opts: P & OptionFlag<T, P>) => Promise<T>;
178
- export type ArgParser<T, P = CustomOptions> = (input: string, context: Command, opts: P & Arg<T, P>) => Promise<T>;
177
+ export type FlagParserContext = Command & {
178
+ token: FlagToken;
179
+ };
180
+ export type FlagParser<T, I extends string | boolean, P = CustomOptions> = (input: I, context: FlagParserContext, opts: P & OptionFlag<T, P>) => Promise<T>;
181
+ export type ArgParserContext = Command & {
182
+ token: ArgToken;
183
+ };
184
+ export type ArgParser<T, P = CustomOptions> = (input: string, context: ArgParserContext, opts: P & Arg<T, P>) => Promise<T>;
179
185
  export type Arg<T, P = CustomOptions> = ArgProps & {
180
186
  options?: T[];
181
187
  defaultHelp?: ArgDefaultHelp<T>;
@@ -185,18 +185,18 @@ class Parser {
185
185
  else {
186
186
  flags[token.flag] = true;
187
187
  }
188
- flags[token.flag] = await this._parseFlag(flags[token.flag], flag);
188
+ flags[token.flag] = await this._parseFlag(flags[token.flag], flag, token);
189
189
  }
190
190
  else {
191
191
  const input = token.input;
192
192
  this._validateOptions(flag, input);
193
193
  if (flag.delimiter && flag.multiple) {
194
- const values = await Promise.all(input.split(flag.delimiter).map(async (v) => this._parseFlag(v.trim(), flag)));
194
+ const values = await Promise.all(input.split(flag.delimiter).map(async (v) => this._parseFlag(v.trim(), flag, token)));
195
195
  flags[token.flag] = flags[token.flag] || [];
196
196
  flags[token.flag].push(...values);
197
197
  }
198
198
  else {
199
- const value = await this._parseFlag(input, flag);
199
+ const value = await this._parseFlag(input, flag, token);
200
200
  if (flag.multiple) {
201
201
  flags[token.flag] = flags[token.flag] || [];
202
202
  flags[token.flag].push(value);
@@ -232,14 +232,14 @@ class Parser {
232
232
  }
233
233
  return flags;
234
234
  }
235
- async _parseFlag(input, flag) {
235
+ async _parseFlag(input, flag, token) {
236
236
  if (!flag.parse)
237
237
  return input;
238
238
  try {
239
239
  if (flag.type === 'boolean') {
240
- return await flag.parse(input, this.context, flag);
240
+ return await flag.parse(input, { ...this.context, token }, flag);
241
241
  }
242
- return flag.parse ? await flag.parse(input, this.context, flag) : input;
242
+ return flag.parse ? await flag.parse(input, { ...this.context, token }, flag) : input;
243
243
  }
244
244
  catch (error) {
245
245
  error.message = `Parsing --${flag.name} \n\t${error.message}\nSee more help with --help`;
@@ -261,7 +261,7 @@ class Parser {
261
261
  if (arg.options && !arg.options.includes(token.input)) {
262
262
  throw new errors_1.ArgInvalidOptionError(arg, token.input);
263
263
  }
264
- const parsed = await arg.parse(token.input, this.context, arg);
264
+ const parsed = await arg.parse(token.input, { ...this.context, token }, arg);
265
265
  argv.push(parsed);
266
266
  args[token.arg] = parsed;
267
267
  }
@@ -269,7 +269,7 @@ class Parser {
269
269
  let stdin = await readStdin();
270
270
  if (stdin) {
271
271
  stdin = stdin.trim();
272
- const parsed = await arg.parse(stdin, this.context, arg);
272
+ const parsed = await arg.parse(stdin, { ...this.context, token }, arg);
273
273
  argv.push(parsed);
274
274
  args[name] = parsed;
275
275
  }
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.0.6",
4
+ "version": "2.0.8",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {