@@ -34,37 +34,27 @@ public function __construct(OutputInterface $output, HandlerInterface $log)
3434
3535 public function command (Host $ host , string $ type , string $ command ): void
3636 {
37- // -v for run command
3837 if ($ this ->output ->isVerbose ()) {
3938 $ this ->output ->writeln ("[ $ host] <fg=green;options=bold> $ type</> $ command " );
4039 }
4140 $ this ->fileLog ->log ("[ {$ host ->getAlias ()}] $ type: $ command " );
4241 }
4342
44- /**
45- * Returns a callable for use with the symfony Process->run($callable) method.
46- *
47- * @return callable A function expecting a int $type (e.g. Process::OUT or Process::ERR) and string $buffer parameters.
48- */
49- public function callback (Host $ host , bool $ forceOutput ): callable
43+ public function print (Host $ host , string $ buffer , bool $ force = false ): void
5044 {
51- return function ($ type , $ buffer ) use ($ forceOutput , $ host ) {
52- if ($ this ->output ->isVerbose () || $ forceOutput ) {
53- $ this ->printBuffer ($ type , $ host , $ buffer );
45+ if ($ this ->output ->isVerbose () || $ force ) {
46+ foreach (explode ("\n" , rtrim ($ buffer )) as $ line ) {
47+ if (empty ($ line )) {
48+ return ;
49+ }
50+ $ this ->output ->writeln ("[ $ host] $ line " );
5451 }
55- };
56- }
57-
58- /**
59- * @param string $type Process::OUT or Process::ERR
60- */
61- public function printBuffer (string $ type , Host $ host , string $ buffer ): void
62- {
52+ }
6353 foreach (explode ("\n" , rtrim ($ buffer )) as $ line ) {
6454 if (empty ($ line )) {
6555 return ;
6656 }
67- $ this ->output -> writeln ("[ $ host] $ line " );
57+ $ this ->fileLog -> log ("[ { $ host-> getAlias ()} ] $ line " );
6858 }
6959 }
7060
0 commit comments