24
24
25
25
/**
26
26
* Class ChainCommand
27
+ *
27
28
* @package Drupal\Console\Core\Command\Chain
28
29
*/
29
30
class ChainCommand extends Command
@@ -43,6 +44,7 @@ class ChainCommand extends Command
43
44
44
45
/**
45
46
* ChainCommand constructor.
47
+ *
46
48
* @param ChainQueue $chainQueue
47
49
* @param ChainDiscovery $chainDiscovery
48
50
*/
@@ -292,6 +294,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
292
294
$ commands = $ configData ['commands ' ];
293
295
}
294
296
297
+ $ parameterOptions = $ input ->getOptions ();
298
+ unset($ parameterOptions ['file ' ]);
299
+
295
300
foreach ($ commands as $ command ) {
296
301
$ moduleInputs = [];
297
302
$ arguments = !empty ($ command ['arguments ' ]) ? $ command ['arguments ' ] : [];
@@ -305,11 +310,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
305
310
$ moduleInputs ['-- ' .$ key ] = is_null ($ value ) ? '' : $ value ;
306
311
}
307
312
308
- $ parameterOptions = $ input ->getOptions ();
309
- unset($ parameterOptions ['file ' ]);
310
- foreach ($ parameterOptions as $ key => $ value ) {
311
- if ($ value ===true ) {
312
- $ moduleInputs ['-- ' . $ key ] = true ;
313
+ foreach ($ this ->getApplication ()->getDefinition ()->getOptions () as $ option ) {
314
+ $ optionName = $ option ->getName ();
315
+ if (array_key_exists ($ optionName , $ parameterOptions )) {
316
+ $ optionValue = $ parameterOptions [$ optionName ];
317
+ if ($ optionValue ) {
318
+ $ moduleInputs ['-- ' . $ optionName ] = $ optionValue ;
319
+ }
313
320
}
314
321
}
315
322
@@ -320,13 +327,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
320
327
continue ;
321
328
}
322
329
330
+ $ io ->text ($ command ['command ' ]);
331
+ $ io ->newLine ();
332
+
323
333
$ input = new ArrayInput ($ moduleInputs );
324
334
if (!is_null ($ interactive )) {
325
- $ input ->setInteractive ($ interactive );
335
+ $ input ->setInteractive ($ interactive );
326
336
}
327
337
328
- $ io ->text ($ command ['command ' ]);
329
- $ callCommand ->run ($ input , $ io );
338
+ $ allowFailure = array_key_exists ('allow_failure ' , $ command )?$ command ['allow_failure ' ]:false ;
339
+ try {
340
+ $ callCommand ->run ($ input , $ io );
341
+ } catch (\Exception $ e ) {
342
+ if (!$ allowFailure ) {
343
+ $ io ->error ($ e ->getMessage ());
344
+ return 1 ;
345
+ }
346
+ }
330
347
}
331
348
332
349
return 0 ;
0 commit comments