@oclif/core 2.11.5 → 2.11.6

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.
@@ -8,7 +8,7 @@ export interface OclifError {
8
8
  }
9
9
  export interface PrettyPrintableError {
10
10
  /**
11
- * messsage to display related to the error
11
+ * message to display related to the error
12
12
  */
13
13
  message?: string;
14
14
  /**
@@ -22,8 +22,9 @@ export declare class InvalidArgsSpecError extends CLIParseError {
22
22
  }
23
23
  export declare class RequiredArgsError extends CLIParseError {
24
24
  args: Arg<any>[];
25
- constructor({ args, parse }: CLIParseErrorOptions & {
25
+ constructor({ args, parse, flagsWithMultiple }: CLIParseErrorOptions & {
26
26
  args: Arg<any>[];
27
+ flagsWithMultiple?: string[];
27
28
  });
28
29
  }
29
30
  export declare class RequiredFlagError extends CLIParseError {
@@ -30,13 +30,18 @@ class InvalidArgsSpecError extends CLIParseError {
30
30
  }
31
31
  exports.InvalidArgsSpecError = InvalidArgsSpecError;
32
32
  class RequiredArgsError extends CLIParseError {
33
- constructor({ args, parse }) {
33
+ constructor({ args, parse, flagsWithMultiple }) {
34
34
  let message = `Missing ${args.length} required arg${args.length === 1 ? '' : 's'}`;
35
35
  const namedArgs = args.filter(a => a.name);
36
36
  if (namedArgs.length > 0) {
37
37
  const list = (0, list_1.renderList)(namedArgs.map(a => [a.name, a.description]));
38
38
  message += `:\n${list}`;
39
39
  }
40
+ if (flagsWithMultiple?.length) {
41
+ const flags = flagsWithMultiple.map(f => `--${f}`).join(', ');
42
+ message += `\n\nNote: ${flags} allow${flagsWithMultiple.length === 1 ? 's' : ''} multiple values. Because of this you need to provide all arguments before providing ${flagsWithMultiple.length === 1 ? 'that flag' : 'those flags'}.`;
43
+ message += '\nAlternatively, you can use "--" to signify the end of the flags and the beginning of arguments.';
44
+ }
40
45
  super({ parse, message });
41
46
  this.args = args;
42
47
  }
@@ -30,7 +30,10 @@ async function validate(parse) {
30
30
  }
31
31
  }
32
32
  if (missingRequiredArgs.length > 0) {
33
- throw new errors_1.RequiredArgsError({ parse, args: missingRequiredArgs });
33
+ const flagsWithMultiple = Object.entries(parse.input.flags)
34
+ .filter(([_, flagDef]) => flagDef.type === 'option' && Boolean(flagDef.multiple))
35
+ .map(([name]) => name);
36
+ throw new errors_1.RequiredArgsError({ parse, args: missingRequiredArgs, flagsWithMultiple });
34
37
  }
35
38
  }
36
39
  async function validateFlags() {
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.11.5",
4
+ "version": "2.11.6",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {