@oclif/core 2.11.5 → 2.11.7
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/command.js +1 -1
- package/lib/interfaces/errors.d.ts +1 -1
- package/lib/parser/errors.d.ts +2 -1
- package/lib/parser/errors.js +6 -1
- package/lib/parser/validate.js +4 -1
- package/package.json +1 -1
package/lib/command.js
CHANGED
|
@@ -165,7 +165,7 @@ class Command {
|
|
|
165
165
|
const jsonIndex = this.argv.indexOf('--json');
|
|
166
166
|
return jsonIndex > -1 && (ptIndex === -1 || jsonIndex < ptIndex);
|
|
167
167
|
}
|
|
168
|
-
return this.argv.includes('--json');
|
|
168
|
+
return this.argv.includes('--json') || this.config.scopedEnvVar?.('CONTENT_TYPE')?.toLowerCase() === 'json';
|
|
169
169
|
}
|
|
170
170
|
async init() {
|
|
171
171
|
this.debug('init version: %s argv: %o', this.ctor._base, this.argv);
|
package/lib/parser/errors.d.ts
CHANGED
|
@@ -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 {
|
package/lib/parser/errors.js
CHANGED
|
@@ -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
|
}
|
package/lib/parser/validate.js
CHANGED
|
@@ -30,7 +30,10 @@ async function validate(parse) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
if (missingRequiredArgs.length > 0) {
|
|
33
|
-
|
|
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() {
|