bob-core 0.8.1 → 0.8.3

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/Command.d.ts CHANGED
@@ -16,6 +16,12 @@ export declare abstract class Command<C = undefined> extends CommandHelper {
16
16
  get command(): string;
17
17
  protected abstract handle(): Promise<void | number>;
18
18
  run(ctx: C, ...args: any[]): Promise<number>;
19
- protected option<T = string | number | boolean | string[] | number[]>(key: string, defaultValue?: T | null): T | null;
20
- protected argument<T = string | number | boolean | string[] | number[]>(key: string, defaultValue?: T | null): T | null;
19
+ protected option(key: string, defaultValue?: any | null): any | null;
20
+ protected optionBoolean(key: string, defaultValue?: boolean): boolean;
21
+ protected optionArray(key: string, defaultValue?: string[]): string[];
22
+ protected optionNumber(key: string, defaultValue?: number | null): number | null;
23
+ protected argument(key: string, defaultValue?: any | null): any | null;
24
+ protected argumentArray(key: string, defaultValue?: string[]): string[];
25
+ protected argumentBoolean(key: string, defaultValue?: boolean): boolean;
26
+ protected argumentNumber(key: string, defaultValue?: number | null): number | null;
21
27
  }
package/dist/Command.js CHANGED
@@ -26,8 +26,26 @@ class Command extends CommandHelper_1.CommandHelper {
26
26
  option(key, defaultValue = null) {
27
27
  return this.parser.option(key) ?? defaultValue;
28
28
  }
29
+ optionBoolean(key, defaultValue = false) {
30
+ return this.parser.option(key) ?? defaultValue;
31
+ }
32
+ optionArray(key, defaultValue = []) {
33
+ return this.parser.option(key) ?? defaultValue;
34
+ }
35
+ optionNumber(key, defaultValue = null) {
36
+ return this.parser.option(key) ? parseInt(this.parser.option(key)) : defaultValue;
37
+ }
29
38
  argument(key, defaultValue = null) {
30
39
  return this.parser.argument(key) ?? defaultValue;
31
40
  }
41
+ argumentArray(key, defaultValue = []) {
42
+ return this.parser.argument(key) ?? defaultValue;
43
+ }
44
+ argumentBoolean(key, defaultValue = false) {
45
+ return this.parser.argument(key) ?? defaultValue;
46
+ }
47
+ argumentNumber(key, defaultValue = null) {
48
+ return this.parser.argument(key) ? parseInt(this.parser.argument(key)) : defaultValue;
49
+ }
32
50
  }
33
51
  exports.Command = Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bob-core",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "BOB Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",