@@ -46,30 +46,32 @@ type GoDev struct {
46
46
func (godev * GoDev ) Start () {
47
47
defer godev .logger .Infof ("godev has ended" )
48
48
godev .logger .Infof ("godev has started" )
49
- if godev .config .RunVersion || godev .config .RunView {
50
- // do nothing
49
+ if godev .config .RunDefault || godev .config .RunTest {
50
+ godev . startWatching ()
51
51
} else if godev .config .RunInit {
52
52
godev .initialiseDirectory ()
53
- } else {
54
- godev .startWatching ()
55
53
}
56
54
}
57
55
58
56
func (godev * GoDev ) createPipeline () []* ExecutionGroup {
59
57
var pipeline []* ExecutionGroup
60
- for _ , execGroup := range godev .config .ExecGroups {
58
+ for execGroupIndex , execGroup := range godev .config .ExecGroups {
61
59
executionGroup := & ExecutionGroup {}
62
60
var executionCommands []* Command
63
61
commands := strings .Split (execGroup , godev .config .CommandsDelimiter )
64
62
for _ , command := range commands {
65
63
if sections , err := shellquote .Split (command ); err != nil {
66
64
panic (err )
67
65
} else {
66
+ arguments := sections [1 :]
67
+ if execGroupIndex == len (godev .config .ExecGroups )- 1 {
68
+ arguments = append (arguments , godev .config .CommandArguments ... )
69
+ }
68
70
executionCommands = append (
69
71
executionCommands ,
70
72
InitCommand (& CommandConfig {
71
73
Application : sections [0 ],
72
- Arguments : sections [ 1 :] ,
74
+ Arguments : arguments ,
73
75
Directory : godev .config .WorkDirectory ,
74
76
Environment : godev .config .EnvVars ,
75
77
LogLevel : godev .config .LogLevel ,
@@ -91,53 +93,6 @@ func (godev *GoDev) eventHandler(events *[]WatcherEvent) bool {
91
93
return true
92
94
}
93
95
94
- func (godev * GoDev ) startWatching () {
95
- godev .logUniversalConfigurations ()
96
- godev .logWatchModeConfigurations ()
97
- godev .initialiseWatcher ()
98
- godev .initialiseRunner ()
99
-
100
- var wg sync.WaitGroup
101
- godev .watcher .BeginWatch (& wg , godev .eventHandler )
102
- godev .logger .Infof ("working dir : '%s'" , godev .config .WorkDirectory )
103
- godev .logger .Infof ("watching dir: '%s'" , godev .config .WatchDirectory )
104
- godev .runner .Trigger ()
105
- wg .Wait ()
106
- }
107
-
108
- func (godev * GoDev ) logUniversalConfigurations () {
109
- godev .logger .Debugf ("flag - init : %v" , godev .config .RunInit )
110
- godev .logger .Debugf ("flag - test : %v" , godev .config .RunTest )
111
- godev .logger .Debugf ("flag - view : %v" , godev .config .RunView )
112
- godev .logger .Debugf ("watch directory : %s" , godev .config .WatchDirectory )
113
- godev .logger .Debugf ("work directory : %s" , godev .config .WorkDirectory )
114
- godev .logger .Debugf ("build output : %s" , godev .config .BuildOutput )
115
- }
116
-
117
- func (godev * GoDev ) logWatchModeConfigurations () {
118
- config := godev .config
119
- logger := godev .logger
120
- logger .Debugf ("environment : %v" , config .EnvVars )
121
- logger .Debugf ("file extensions : %v" , config .FileExtensions )
122
- logger .Debugf ("ignored names : %v" , config .IgnoredNames )
123
- logger .Debugf ("refresh interval : %v" , config .Rate )
124
- logger .Debugf ("execution delim : %s" , config .CommandsDelimiter )
125
- logger .Debug ("execution groups as follows..." )
126
- for egIndex , execGroup := range config .ExecGroups {
127
- logger .Debugf (" %v) %s" , egIndex + 1 , execGroup )
128
- commands := strings .Split (execGroup , config .CommandsDelimiter )
129
- for cIndex , command := range commands {
130
- sections , err := shellquote .Split (command )
131
- if err != nil {
132
- panic (err )
133
- }
134
- app := sections [0 ]
135
- args := sections [1 :]
136
- logger .Debugf (" %v > %s %v" , cIndex + 1 , app , args )
137
- }
138
- }
139
- }
140
-
141
96
func (godev * GoDev ) initialiseInitialisers () []Initialiser {
142
97
return []Initialiser {
143
98
InitGitInitialiser (& GitInitialiserConfig {
@@ -218,3 +173,53 @@ func (godev *GoDev) initialiseWatcher() {
218
173
})
219
174
godev .watcher .RecursivelyWatch (godev .config .WatchDirectory )
220
175
}
176
+
177
+ func (godev * GoDev ) logUniversalConfigurations () {
178
+ godev .logger .Debugf ("flag - init : %v" , godev .config .RunInit )
179
+ godev .logger .Debugf ("flag - test : %v" , godev .config .RunTest )
180
+ godev .logger .Debugf ("flag - view : %v" , godev .config .RunView )
181
+ godev .logger .Debugf ("watch directory : %s" , godev .config .WatchDirectory )
182
+ godev .logger .Debugf ("work directory : %s" , godev .config .WorkDirectory )
183
+ godev .logger .Debugf ("build output : %s" , godev .config .BuildOutput )
184
+ }
185
+
186
+ func (godev * GoDev ) logWatchModeConfigurations () {
187
+ config := godev .config
188
+ logger := godev .logger
189
+ logger .Debugf ("environment : %v" , config .EnvVars )
190
+ logger .Debugf ("file extensions : %v" , config .FileExtensions )
191
+ logger .Debugf ("ignored names : %v" , config .IgnoredNames )
192
+ logger .Debugf ("refresh interval : %v" , config .Rate )
193
+ logger .Debugf ("execution delim : %s" , config .CommandsDelimiter )
194
+ logger .Debug ("execution groups as follows..." )
195
+ for execGroupIndex , execGroup := range config .ExecGroups {
196
+ logger .Debugf (" %v) %s" , execGroupIndex + 1 , execGroup )
197
+ commands := strings .Split (execGroup , config .CommandsDelimiter )
198
+ for commandIndex , command := range commands {
199
+ sections , err := shellquote .Split (command )
200
+ if err != nil {
201
+ panic (err )
202
+ }
203
+ application := sections [0 ]
204
+ arguments := sections [1 :]
205
+ if execGroupIndex == len (config .ExecGroups )- 1 {
206
+ arguments = append (arguments , config .CommandArguments ... )
207
+ }
208
+ logger .Debugf (" %v > %s %v" , commandIndex + 1 , application , arguments )
209
+ }
210
+ }
211
+ }
212
+
213
+ func (godev * GoDev ) startWatching () {
214
+ godev .logUniversalConfigurations ()
215
+ godev .logWatchModeConfigurations ()
216
+ godev .initialiseWatcher ()
217
+ godev .initialiseRunner ()
218
+
219
+ var wg sync.WaitGroup
220
+ godev .watcher .BeginWatch (& wg , godev .eventHandler )
221
+ godev .logger .Infof ("working dir : '%s'" , godev .config .WorkDirectory )
222
+ godev .logger .Infof ("watching dir: '%s'" , godev .config .WatchDirectory )
223
+ godev .runner .Trigger ()
224
+ wg .Wait ()
225
+ }
0 commit comments