@oclif/core 1.3.6 → 1.4.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 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.4.0](https://github.com/oclif/core/compare/v1.3.6...v1.4.0) (2022-03-01)
6
+
7
+
8
+ ### Features
9
+
10
+ * make global flags settable ([#385](https://github.com/oclif/core/issues/385)) ([e14061c](https://github.com/oclif/core/commit/e14061ca7e6a4c288eb50e0e9954b38e042682df))
11
+
5
12
  ### [1.3.6](https://github.com/oclif/core/compare/v1.3.5...v1.3.6) (2022-02-28)
6
13
 
7
14
 
package/lib/command.d.ts CHANGED
@@ -63,9 +63,11 @@ export default abstract class Command {
63
63
  * @param {Interfaces.LoadOptions} opts options
64
64
  */
65
65
  static run: Interfaces.Command.Class['run'];
66
- private static globalFlags;
66
+ protected static _globalFlags: Interfaces.FlagInput<any>;
67
+ static get globalFlags(): Interfaces.FlagInput<any>;
68
+ static set globalFlags(flags: Interfaces.FlagInput<any>);
67
69
  /** A hash of flags for the command */
68
- private static _flags;
70
+ protected static _flags: Interfaces.FlagInput<any>;
69
71
  static get flags(): Interfaces.FlagInput<any>;
70
72
  static set flags(flags: Interfaces.FlagInput<any>);
71
73
  id: string | undefined;
package/lib/command.js CHANGED
@@ -17,6 +17,12 @@ process.stdout.on('error', (err) => {
17
17
  return;
18
18
  throw err;
19
19
  });
20
+ const jsonFlag = {
21
+ json: Flags.boolean({
22
+ description: 'Format output as json.',
23
+ helpGroup: 'GLOBAL',
24
+ }),
25
+ };
20
26
  /**
21
27
  * An abstract class which acts as the base for each command
22
28
  * in your project.
@@ -33,11 +39,20 @@ class Command {
33
39
  this.debug = () => { };
34
40
  }
35
41
  }
42
+ static get globalFlags() {
43
+ return this._globalFlags;
44
+ }
45
+ static set globalFlags(flags) {
46
+ this._globalFlags = this.enableJsonFlag ?
47
+ Object.assign({}, jsonFlag, this.globalFlags, flags) :
48
+ Object.assign({}, this.globalFlags, flags);
49
+ }
36
50
  static get flags() {
37
51
  return this._flags;
38
52
  }
39
53
  static set flags(flags) {
40
- this._flags = this.enableJsonFlag ? Object.assign({}, Command.globalFlags, flags) : flags;
54
+ this.globalFlags = {};
55
+ this._flags = Object.assign({}, this.globalFlags, flags);
41
56
  }
42
57
  get ctor() {
43
58
  return this.constructor;
@@ -169,9 +184,3 @@ Command.run = async function (argv, opts) {
169
184
  const cmd = new this(argv, config);
170
185
  return cmd._run(argv);
171
186
  };
172
- Command.globalFlags = {
173
- json: Flags.boolean({
174
- description: 'Format output as json.',
175
- helpGroup: 'GLOBAL',
176
- }),
177
- };
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": "1.3.6",
4
+ "version": "1.4.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {