22
33namespace Oliverde8 \PhpEtlBundle \Command ;
44
5+ use Oliverde8 \Component \PhpEtl \Output \SymfonyConsoleOutput ;
56use Oliverde8 \PhpEtlBundle \Services \ChainProcessorsManager ;
67use Symfony \Component \Console \Command \Command ;
78use Symfony \Component \Console \Input \InputArgument ;
89use Symfony \Component \Console \Input \InputInterface ;
10+ use Symfony \Component \Console \Input \InputOption ;
911use Symfony \Component \Console \Output \OutputInterface ;
1012
1113class ExecuteCommand extends Command
1214{
1315 const ARGUMENT_NAME = "name " ;
1416 const ARGUMENT_DATA = "data " ;
1517 const ARGUMENT_PARAMS = "params " ;
18+ const OPTION_PRETTY = "pretty " ;
1619
1720 protected ChainProcessorsManager $ chainProcessorsManager ;
1821
@@ -32,6 +35,7 @@ protected function configure()
3235 $ this ->addArgument (self ::ARGUMENT_NAME , InputArgument::REQUIRED );
3336 $ this ->addArgument (self ::ARGUMENT_DATA , InputArgument::OPTIONAL , "json with the input array " );
3437 $ this ->addArgument (self ::ARGUMENT_PARAMS , InputArgument::OPTIONAL , "json with all the additional parameters " );
38+ $ this ->addOption (self ::OPTION_PRETTY , "p " , InputOption::VALUE_NONE , "Disables pretty output " );
3539 }
3640
3741 /**
@@ -43,7 +47,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
4347 $ options = json_decode ($ input ->getArgument (self ::ARGUMENT_PARAMS ) ?? '[] ' , true );
4448 $ data = json_decode ($ input ->getArgument (self ::ARGUMENT_DATA ) ?? '[] ' , true );
4549
46- $ this ->chainProcessorsManager ->execute ($ chainName , $ data , $ options );
50+ $ processorOutput = new SymfonyConsoleOutput ($ output , 0 );
51+ $ observation = function (array $ operationStates ) use ($ processorOutput ) {
52+ $ processorOutput ->output ($ operationStates );
53+ };
54+ if ($ input ->getOption (self ::OPTION_PRETTY )) {
55+ $ observation = function (array $ operationStates ) {};
56+ }
57+
58+ $ this ->chainProcessorsManager ->execute ($ chainName , $ data , $ options , $ observation );
4759 return 0 ;
4860 }
4961}
0 commit comments