@oclif/core 1.13.1 → 1.13.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/CHANGELOG.md +21 -0
- package/lib/command.d.ts +8 -8
- package/lib/command.js +9 -2
- package/lib/interfaces/parser.d.ts +6 -6
- package/lib/parser/index.d.ts +2 -2
- package/lib/parser/index.js +1 -2
- package/lib/parser/validate.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.13.4](https://github.com/oclif/core/compare/v1.13.3...v1.13.4) (2022-08-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* retain enable json flag get/set apply flag at parse ([#460](https://github.com/oclif/core/issues/460)) ([9812937](https://github.com/oclif/core/commit/9812937e43a573cf4a10d4b03fca47555de5a1d9))
|
|
11
|
+
|
|
12
|
+
### [1.13.3](https://github.com/oclif/core/compare/v1.13.2...v1.13.3) (2022-08-06)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* improve flag types ([6d0b4e1](https://github.com/oclif/core/commit/6d0b4e1f1761baba0e085ea8d342a7bc913e7e5d))
|
|
18
|
+
|
|
19
|
+
### [1.13.2](https://github.com/oclif/core/compare/v1.13.1...v1.13.2) (2022-08-05)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* flag types ([#454](https://github.com/oclif/core/issues/454)) ([2938ba4](https://github.com/oclif/core/commit/2938ba4082d1b0c603a55678fe47f5beed9acbb5))
|
|
25
|
+
|
|
5
26
|
### [1.13.1](https://github.com/oclif/core/compare/v1.13.0...v1.13.1) (2022-08-02)
|
|
6
27
|
|
|
7
28
|
|
package/lib/command.d.ts
CHANGED
|
@@ -65,13 +65,13 @@ export default abstract class Command {
|
|
|
65
65
|
* @param {Interfaces.LoadOptions} opts options
|
|
66
66
|
*/
|
|
67
67
|
static run: Interfaces.Command.Class['run'];
|
|
68
|
-
protected static _globalFlags: Interfaces.FlagInput
|
|
69
|
-
static get globalFlags(): Interfaces.FlagInput
|
|
70
|
-
static set globalFlags(flags: Interfaces.FlagInput
|
|
68
|
+
protected static _globalFlags: Interfaces.FlagInput;
|
|
69
|
+
static get globalFlags(): Interfaces.FlagInput;
|
|
70
|
+
static set globalFlags(flags: Interfaces.FlagInput);
|
|
71
71
|
/** A hash of flags for the command */
|
|
72
|
-
protected static _flags: Interfaces.FlagInput
|
|
73
|
-
static get flags(): Interfaces.FlagInput
|
|
74
|
-
static set flags(flags: Interfaces.FlagInput
|
|
72
|
+
protected static _flags: Interfaces.FlagInput;
|
|
73
|
+
static get flags(): Interfaces.FlagInput;
|
|
74
|
+
static set flags(flags: Interfaces.FlagInput);
|
|
75
75
|
id: string | undefined;
|
|
76
76
|
protected debug: (...args: any[]) => void;
|
|
77
77
|
constructor(argv: string[], config: Config);
|
|
@@ -95,9 +95,9 @@ export default abstract class Command {
|
|
|
95
95
|
*/
|
|
96
96
|
abstract run(): PromiseLike<any>;
|
|
97
97
|
protected init(): Promise<any>;
|
|
98
|
-
protected parse<F, A extends {
|
|
98
|
+
protected parse<F, G, A extends {
|
|
99
99
|
[name: string]: any;
|
|
100
|
-
}>(options?: Interfaces.Input<F>, argv?: string[]): Promise<Interfaces.ParserOutput<F, A>>;
|
|
100
|
+
}>(options?: Interfaces.Input<F, G>, argv?: string[]): Promise<Interfaces.ParserOutput<F, G, A>>;
|
|
101
101
|
protected catch(err: Error & {
|
|
102
102
|
exitCode?: number;
|
|
103
103
|
}): Promise<any>;
|
package/lib/command.js
CHANGED
|
@@ -44,8 +44,15 @@ class Command {
|
|
|
44
44
|
}
|
|
45
45
|
static set enableJsonFlag(value) {
|
|
46
46
|
this._enableJsonFlag = value;
|
|
47
|
-
if (value)
|
|
47
|
+
if (value === true) {
|
|
48
48
|
this.globalFlags = jsonFlag;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
delete this.globalFlags.json;
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
delete this.flags.json;
|
|
55
|
+
}
|
|
49
56
|
}
|
|
50
57
|
static get globalFlags() {
|
|
51
58
|
return this._globalFlags;
|
|
@@ -129,7 +136,7 @@ class Command {
|
|
|
129
136
|
options = this.constructor;
|
|
130
137
|
const opts = { context: this, ...options };
|
|
131
138
|
// the spread operator doesn't work with getters so we have to manually add it here
|
|
132
|
-
opts.flags =
|
|
139
|
+
opts.flags = options?.flags;
|
|
133
140
|
return Parser.parse(argv, opts);
|
|
134
141
|
}
|
|
135
142
|
async catch(err) {
|
|
@@ -37,7 +37,7 @@ export declare type ArgInput = Arg<any>[];
|
|
|
37
37
|
export interface CLIParseErrorOptions {
|
|
38
38
|
parse: {
|
|
39
39
|
input?: ParserInput;
|
|
40
|
-
output?: ParserOutput
|
|
40
|
+
output?: ParserOutput;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export declare type OutputArgs = {
|
|
@@ -46,8 +46,8 @@ export declare type OutputArgs = {
|
|
|
46
46
|
export declare type OutputFlags<T extends ParserInput['flags']> = {
|
|
47
47
|
[P in keyof T]: any;
|
|
48
48
|
};
|
|
49
|
-
export declare type ParserOutput<TFlags extends OutputFlags<any
|
|
50
|
-
flags: TFlags & {
|
|
49
|
+
export declare type ParserOutput<TFlags extends OutputFlags<any> = any, GFlags extends OutputFlags<any> = any, TArgs extends OutputArgs = any> = {
|
|
50
|
+
flags: TFlags & GFlags & {
|
|
51
51
|
json: boolean | undefined;
|
|
52
52
|
};
|
|
53
53
|
args: TArgs;
|
|
@@ -158,9 +158,9 @@ export declare type EnumFlagOptions<T> = Partial<OptionFlag<T>> & {
|
|
|
158
158
|
options: T[];
|
|
159
159
|
};
|
|
160
160
|
export declare type Flag<T> = BooleanFlag<T> | OptionFlag<T>;
|
|
161
|
-
export declare type Input<TFlags extends FlagOutput> = {
|
|
161
|
+
export declare type Input<TFlags extends FlagOutput, GFlags extends FlagOutput> = {
|
|
162
162
|
flags?: FlagInput<TFlags>;
|
|
163
|
-
globalFlags?: FlagInput<
|
|
163
|
+
globalFlags?: FlagInput<GFlags>;
|
|
164
164
|
args?: ArgInput;
|
|
165
165
|
strict?: boolean;
|
|
166
166
|
context?: any;
|
|
@@ -194,7 +194,7 @@ export declare type CompletableOptionFlag<T> = OptionFlag<T> & {
|
|
|
194
194
|
completion?: Completion;
|
|
195
195
|
};
|
|
196
196
|
export declare type CompletableFlag<T> = BooleanFlag<T> | CompletableOptionFlag<T>;
|
|
197
|
-
export declare type FlagInput<T extends FlagOutput> = {
|
|
197
|
+
export declare type FlagInput<T extends FlagOutput = object> = {
|
|
198
198
|
[P in keyof T]: CompletableFlag<T[P]>;
|
|
199
199
|
};
|
|
200
200
|
export {};
|
package/lib/parser/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { Input, ParserOutput } from '../interfaces';
|
|
|
5
5
|
export { args };
|
|
6
6
|
export { flags };
|
|
7
7
|
export { flagUsages } from './help';
|
|
8
|
-
export declare function parse<TFlags, TArgs extends {
|
|
8
|
+
export declare function parse<TFlags, GFlags, TArgs extends {
|
|
9
9
|
[name: string]: string;
|
|
10
|
-
}>(argv: string[], options: Input<TFlags>): Promise<ParserOutput<TFlags, TArgs>>;
|
|
10
|
+
}>(argv: string[], options: Input<TFlags, GFlags>): Promise<ParserOutput<TFlags, GFlags, TArgs>>;
|
|
11
11
|
declare const boolean: typeof flags.boolean, integer: (opts?: {
|
|
12
12
|
min?: number | undefined;
|
|
13
13
|
max?: number | undefined;
|
package/lib/parser/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// tslint:disable interface-over-type-literal
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.file = exports.directory = exports.url = exports.integer = exports.boolean = exports.parse = exports.flagUsages = exports.flags = exports.args = void 0;
|
|
5
4
|
const args = require("./args");
|
|
@@ -22,7 +21,7 @@ async function parse(argv, options) {
|
|
|
22
21
|
'--': options['--'],
|
|
23
22
|
flags: {
|
|
24
23
|
color: flags.defaultFlags.color,
|
|
25
|
-
...
|
|
24
|
+
...options.flags,
|
|
26
25
|
},
|
|
27
26
|
strict: options.strict !== false,
|
|
28
27
|
};
|
package/lib/parser/validate.d.ts
CHANGED