Commit 3a121e2 1 parent 2e4367f commit 3a121e2 Copy full SHA for 3a121e2
File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ const { Command } = require('commander');
23
23
24
24
// Constructor
25
25
function Application ( ) {
26
+ this . program = null ;
27
+ this . controllers = [ ] ;
28
+ }
29
+
30
+ Application . prototype . setupCommander = function ( ) {
31
+ // Commander kann nicht mehrfach verwendet werden, sondern muss immer wieder
32
+ // neu geladen werden, siehe https://github.com/tj/commander.js/pull/499
26
33
this . program = new Command ( ) ;
27
34
this . program
28
35
. version ( 'unknown' , '-OV, --original-version' ) ;
@@ -33,16 +40,27 @@ function Application() {
33
40
. action ( ( ) => {
34
41
this . program . output . destroy ( 'Unerwartete Eingabe' ) ;
35
42
} ) ;
43
+
44
+ for ( var i = 0 ; i < this . controllers . length ; i ++ ) {
45
+ var controller = this . controllers [ i ] ;
46
+
47
+ controller . register ( this . program ) ;
48
+ }
36
49
}
37
50
38
51
// class methods
39
52
Application . prototype . addController = function ( controller ) {
40
- controller . register ( this . program ) ;
53
+ this . controllers . push ( controller ) ;
41
54
} ;
42
55
43
56
Application . prototype . run = function ( input , output ) {
57
+ // Setup commander
58
+ this . setupCommander ( ) ;
59
+
44
60
this . program . output = output ;
45
61
this . program . parse ( input . getArgv ( ) ) ;
62
+
63
+ this . program = null ;
46
64
} ;
47
65
48
66
// Factory method
You can’t perform that action at this time.
0 commit comments