@travetto/cli 2.0.1 → 2.1.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/cli",
3
3
  "displayName": "Command Line Interface",
4
- "version": "2.0.1",
4
+ "version": "2.1.0",
5
5
  "description": "CLI infrastructure for travetto framework",
6
6
  "keywords": [
7
7
  "cli",
@@ -27,8 +27,8 @@
27
27
  "directory": "module/cli"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/base": "^2.0.1",
31
- "commander": "^7.2.0"
30
+ "@travetto/base": "^2.1.0",
31
+ "commander": "^9.0.0"
32
32
  },
33
33
  "docDependencies": {
34
34
  "@travetto/app": true
@@ -136,10 +136,20 @@ export abstract class BasePlugin<V extends ParamMap = ParamMap> {
136
136
  .BuildUtil.build();
137
137
  }
138
138
 
139
+ /**
140
+ * Expose configuration as constrained typed object
141
+ */
139
142
  get cmd() {
140
143
  return this.#cmd.opts() as Shape<ReturnType<Exclude<this['getOptions'], undefined>>>;
141
144
  }
142
145
 
146
+ /**
147
+ * Expose command line arguments
148
+ */
149
+ get args() {
150
+ return this.#cmd.args;
151
+ }
152
+
143
153
  /**
144
154
  * Render help with additional message or extra text
145
155
  */
package/src/util.ts CHANGED
@@ -12,7 +12,9 @@ export class CliUtil {
12
12
  return /^(1|0|yes|no|on|off|auto|true|false)$/i.test(x);
13
13
  }
14
14
 
15
- static toBool(x: string | boolean, def: boolean) {
15
+ static toBool(x: string | boolean, def: boolean): boolean;
16
+ static toBool(x?: string | boolean, def?: boolean): boolean | undefined;
17
+ static toBool(x?: string | boolean, def?: boolean) {
16
18
  return x === undefined ? true :
17
19
  (typeof x === 'boolean' ? x :
18
20
  (this.isBoolean(x) ? /^(1|yes|on|true)$/i.test(x) :