File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -23,11 +23,15 @@ export interface CommandParams {
23
23
description ?: string
24
24
}
25
25
26
- export type OptionType = BooleanConstructor | StringConstructor | NumberConstructor | ArrayConstructor
26
+ export type OptionType = BooleanConstructor | StringConstructor | NumberConstructor | ArrayConstructor | [ StringConstructor ]
27
27
28
28
export interface OptionParams {
29
29
name : string
30
30
type ?: OptionType
31
31
description ?: string
32
32
alias ?: string
33
33
}
34
+
35
+ export interface RegisterCommandParams extends CommandParams {
36
+ subOptions ?: OptionParams [ ]
37
+ }
Original file line number Diff line number Diff line change 1
- import { OptionParams , CommandParams } from '../interfaces'
2
-
1
+ import { OptionParams , RegisterCommandParams } from '../interfaces'
3
2
export class RegisterProvider {
4
3
static isRegisterProvider : boolean = true
5
-
4
+
6
5
constructor (
7
- private _commands : CommandParams [ ] = [ ] ,
6
+ private _commands : RegisterCommandParams [ ] = [ ] ,
8
7
private _options : OptionParams [ ] = [ ] ,
9
8
) {
10
9
}
11
-
12
- get commands ( ) : CommandParams [ ] {
10
+
11
+ get commands ( ) : RegisterCommandParams [ ] {
13
12
return this . _commands
14
13
}
15
-
14
+
16
15
get options ( ) : OptionParams [ ] {
17
16
return this . _options
18
17
}
19
-
18
+
20
19
}
Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ import { metadata } from '../constants/metadata'
4
4
export type OptionKeyValue = { [ key : string ] : string }
5
5
6
6
export const commandsToDatas = ( commands : CommandClass [ ] = [ ] ) => {
7
- return commands . map ( fn => Reflect . getMetadata ( metadata . COMMAND_IDENTIFIER , fn ) )
7
+ return commands . map ( fn => Object . assign (
8
+ Reflect . getMetadata ( metadata . COMMAND_IDENTIFIER , fn ) ,
9
+ { subOptions : Reflect . getMetadata ( metadata . SUB_OPTION_IDENTIFIER , fn ) || [ ] } )
10
+ )
8
11
}
9
12
10
13
export const optionsToDatas = ( options : OptionClass [ ] ) => {
You can’t perform that action at this time.
0 commit comments