@oclif/core 1.11.0 → 1.12.0
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 +7 -0
- package/lib/command.d.ts +3 -1
- package/lib/command.js +12 -6
- package/lib/interfaces/parser.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.12.0](https://github.com/oclif/core/compare/v1.11.0...v1.12.0) (2022-07-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* improve the instantiation of global flags ([#445](https://github.com/oclif/core/issues/445)) ([d264535](https://github.com/oclif/core/commit/d2645358ccf1cddd0bb65d236e73ecf4c5ac7c0c))
|
|
11
|
+
|
|
5
12
|
## [1.11.0](https://github.com/oclif/core/compare/v1.10.0...v1.11.0) (2022-07-18)
|
|
6
13
|
|
|
7
14
|
|
package/lib/command.d.ts
CHANGED
|
@@ -55,7 +55,9 @@ export default abstract class Command {
|
|
|
55
55
|
*/
|
|
56
56
|
static examples: Interfaces.Example[];
|
|
57
57
|
static parserOptions: {};
|
|
58
|
-
static
|
|
58
|
+
static _enableJsonFlag: boolean;
|
|
59
|
+
static get enableJsonFlag(): boolean;
|
|
60
|
+
static set enableJsonFlag(value: boolean);
|
|
59
61
|
/**
|
|
60
62
|
* instantiate and run the command
|
|
61
63
|
* @param {Interfaces.Command.Class} this Class
|
package/lib/command.js
CHANGED
|
@@ -39,19 +39,25 @@ class Command {
|
|
|
39
39
|
this.debug = () => { };
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
static get enableJsonFlag() {
|
|
43
|
+
return this._enableJsonFlag;
|
|
44
|
+
}
|
|
45
|
+
static set enableJsonFlag(value) {
|
|
46
|
+
this._enableJsonFlag = value;
|
|
47
|
+
if (value)
|
|
48
|
+
this.globalFlags = jsonFlag;
|
|
49
|
+
}
|
|
42
50
|
static get globalFlags() {
|
|
43
51
|
return this._globalFlags;
|
|
44
52
|
}
|
|
45
53
|
static set globalFlags(flags) {
|
|
46
|
-
this._globalFlags = this.
|
|
47
|
-
|
|
48
|
-
Object.assign({}, this.globalFlags, flags);
|
|
54
|
+
this._globalFlags = Object.assign({}, this.globalFlags, flags);
|
|
55
|
+
this.flags = this.globalFlags;
|
|
49
56
|
}
|
|
50
57
|
static get flags() {
|
|
51
58
|
return this._flags;
|
|
52
59
|
}
|
|
53
60
|
static set flags(flags) {
|
|
54
|
-
this.globalFlags = {};
|
|
55
61
|
this._flags = Object.assign({}, this.globalFlags, flags);
|
|
56
62
|
}
|
|
57
63
|
get ctor() {
|
|
@@ -123,7 +129,7 @@ class Command {
|
|
|
123
129
|
options = this.constructor;
|
|
124
130
|
const opts = { context: this, ...options };
|
|
125
131
|
// the spread operator doesn't work with getters so we have to manually add it here
|
|
126
|
-
opts.flags = options === null || options === void 0 ? void 0 : options.flags;
|
|
132
|
+
opts.flags = Object.assign({}, options === null || options === void 0 ? void 0 : options.flags, options === null || options === void 0 ? void 0 : options.globalFlags);
|
|
127
133
|
return Parser.parse(argv, opts);
|
|
128
134
|
}
|
|
129
135
|
async catch(err) {
|
|
@@ -169,7 +175,7 @@ Command.aliases = [];
|
|
|
169
175
|
Command.strict = true;
|
|
170
176
|
Command.parse = true;
|
|
171
177
|
Command.parserOptions = {};
|
|
172
|
-
Command.
|
|
178
|
+
Command._enableJsonFlag = false;
|
|
173
179
|
// eslint-disable-next-line valid-jsdoc
|
|
174
180
|
/**
|
|
175
181
|
* instantiate and run the command
|
|
@@ -160,6 +160,7 @@ export declare type EnumFlagOptions<T> = Partial<OptionFlag<T>> & {
|
|
|
160
160
|
export declare type Flag<T> = BooleanFlag<T> | OptionFlag<T>;
|
|
161
161
|
export declare type Input<TFlags extends FlagOutput> = {
|
|
162
162
|
flags?: FlagInput<TFlags>;
|
|
163
|
+
globalFlags?: FlagInput<TFlags>;
|
|
163
164
|
args?: ArgInput;
|
|
164
165
|
strict?: boolean;
|
|
165
166
|
context?: any;
|