@cabloy/cli 3.0.58 → 3.0.59

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/dist/lib/cli.d.ts CHANGED
@@ -39,4 +39,5 @@ export declare class CliCommand extends BaseCommand {
39
39
  group: any;
40
40
  context: any;
41
41
  }): any;
42
+ _prepareArgv(argv: any): any;
42
43
  }
package/dist/lib/cli.js CHANGED
@@ -12,9 +12,9 @@ export class CliCommand extends BaseCommand {
12
12
  __argv;
13
13
  constructor(rawArgv, { meta, argv }) {
14
14
  super(rawArgv);
15
- this.usage = meta.info.usage;
15
+ // this.usage = meta.info.usage; // readonly
16
+ // this.options = meta.options; // readonly
16
17
  this.version = meta.info.version;
17
- this.options = meta.options;
18
18
  this.__meta = meta;
19
19
  this.__groups = meta.groups;
20
20
  this.__argv = argv;
@@ -22,8 +22,7 @@ export class CliCommand extends BaseCommand {
22
22
  async run(options) {
23
23
  let { argv, cwd, env, rawArgv } = options;
24
24
  // argv
25
- argv = Object.assign({}, argv, this.__argv);
26
- delete argv.$0;
25
+ argv = this._prepareArgv(argv);
27
26
  // context
28
27
  const context = {
29
28
  brandName: process.env.CabloyCliBrandName,
@@ -200,4 +199,19 @@ export class CliCommand extends BaseCommand {
200
199
  return true;
201
200
  return evaluate(expression, { group, context });
202
201
  }
202
+ _prepareArgv(argv) {
203
+ argv = Object.assign({}, argv, this.__argv);
204
+ delete argv.$0;
205
+ // alias
206
+ const options = this.__meta.options;
207
+ if (options) {
208
+ for (const key in options) {
209
+ const option = options[key];
210
+ if (option.alias && argv[key] === undefined) {
211
+ argv[key] = argv[option.alias];
212
+ }
213
+ }
214
+ }
215
+ return argv;
216
+ }
203
217
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cabloy/cli",
3
3
  "type": "module",
4
- "version": "3.0.58",
4
+ "version": "3.0.59",
5
5
  "description": "@cabloy/cli",
6
6
  "publishConfig": {
7
7
  "access": "public"