File tree 4 files changed +17
-7
lines changed
4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,13 @@ var Handler = require('./autobot/handler');
2
2
var access = require ( './lib/resource_accessor' ) . access ;
3
3
var Adapters = require ( './autobot/adapters' ) ;
4
4
var googleCore = require ( './autobot/core/core' ) . google ;
5
+ var defaultCore = require ( './autobot/core/core' ) . default ;
5
6
6
7
class Autobot {
7
- constructor ( adapter ) {
8
+ constructor ( adapter , coreType = 'default' ) {
8
9
var adapterClass = access ( Adapters , adapter ) ;
9
- this . adapter = new adapterClass ( googleCore ) ;
10
+ if ( coreType == 'google' ) { this . adapter = new adapterClass ( googleCore ) ; }
11
+ else { this . adapter = new adapterClass ( defaultCore ) ; }
10
12
}
11
13
12
14
receive ( input , callback ) {
Original file line number Diff line number Diff line change @@ -30,11 +30,11 @@ class Cli extends Adapter {
30
30
for more intelligent mapping.
31
31
*/
32
32
parse ( input ) {
33
- return parsePlankTimes ( input ) ;
34
- /*
35
- var tokens = input.trim().split(' ');
36
- return { command: tokens[0], args: tokens.slice(1) }
37
- */
33
+ if ( this . core . type ( ) == 'google' ) { return parsePlankTimes ( input ) ; }
34
+ else if ( this . core . type ( ) == 'default' ) {
35
+ var tokens = input . trim ( ) . split ( ' ' ) ;
36
+ return { command : tokens [ 0 ] , args : tokens . slice ( 1 ) }
37
+ }
38
38
}
39
39
40
40
Original file line number Diff line number Diff line change @@ -33,9 +33,14 @@ class Core {
33
33
return cmd ( args ) ;
34
34
}
35
35
}
36
+
37
+ type ( ) {
38
+ return access ( this . commands , 'type' ) . bind ( this ) . call ( ) ;
39
+ }
36
40
}
37
41
38
42
var defaultCommands = {
43
+ type : function ( ) { return 'default' ; } ,
39
44
/*
40
45
A simple echo call.
41
46
@@ -68,6 +73,8 @@ var defaultCommands = {
68
73
}
69
74
70
75
var googleCommands = {
76
+ type : function ( ) { return 'google' ; } ,
77
+
71
78
get : function ( args ) {
72
79
return this . resource . get ( args ) ;
73
80
} ,
Original file line number Diff line number Diff line change 17
17
"scripts" : {
18
18
"start" : " node ./main/autobot/cli.js" ,
19
19
"pretest" : " rsync -av --ignore-existing ./configs/jira_credentials.js.example ./configs/jira_credentials.js" ,
20
+ "pretest" : " rsync -av --ignore-existing ./configs/user_mappings.js.example ./configs/user_mappings.js" ,
20
21
"test" : " mocha --recursive"
21
22
},
22
23
"dependencies" : {
You can’t perform that action at this time.
0 commit comments