@@ -315,6 +315,11 @@ protected function _launchShell()
315315 }
316316 }
317317
318+ public function executeCmdCall ($ cmd )
319+ {
320+ return $ this ->_routeCliCmdCall ($ cmd );
321+ }
322+
318323 public function dispatchCmdCall ($ cmd , array $ args )
319324 {
320325 $ this ->_preRoutingShellCmd ($ cmd , $ args );
@@ -328,6 +333,7 @@ protected function _preRoutingShellCmd(&$cmd, array &$args)
328333 foreach ($ args as &$ arg ) {
329334 $ arg = preg_replace ('#^("| \')|("| \')$#i ' , '' , $ arg );
330335 }
336+ unset($ arg );
331337
332338 $ this ->displayWaitingMsg (false , false );
333339 }
@@ -380,7 +386,7 @@ protected function _routeShellStatus($cmd, $status)
380386 $ this ->error ($ this ->_manCommands [$ cmd ], 'red ' );
381387 }
382388 else {
383- $ this ->error ("Une erreur s'est produit lors de l'exécution de cette commande " , 'red ' );
389+ $ this ->error ("Une erreur s'est produite lors de l'exécution de cette commande " , 'red ' );
384390 }
385391 }
386392
@@ -442,6 +448,14 @@ public function format($text, $textColor = 'green', $bgColor = false, $textStyle
442448 return $ this ->_e ($ text , $ textColor , $ bgColor , $ textStyle , true );
443449 }
444450
451+ /**
452+ * @param int $multiplier
453+ * @param string $textColor
454+ * @param string $bgColor
455+ * @param string $textStyle
456+ * @param bool $autoDelWaitingMsg
457+ * @return $this
458+ */
445459 public function EOL ($ multiplier = 1 , $ textColor = false , $ bgColor = false , $ textStyle = false , $ autoDelWaitingMsg = true )
446460 {
447461 if ($ autoDelWaitingMsg ) {
@@ -452,6 +466,32 @@ public function EOL($multiplier = 1, $textColor = false, $bgColor = false, $text
452466 return $ this ; // /!\ Important
453467 }
454468
469+ /**
470+ * @param string $text
471+ * @param string $textColor
472+ * @param string $bgColor
473+ * @param string $textStyle
474+ * @param bool $autoDelWaitingMsg
475+ * @return $this
476+ */
477+ public function echo ($ text , $ textColor = 'green ' , $ bgColor = false , $ textStyle = false , $ autoDelWaitingMsg = true )
478+ {
479+ if ($ autoDelWaitingMsg ) {
480+ $ this ->deleteWaitingMsg ();
481+ }
482+
483+ $ this ->_e ($ text , $ textColor , $ bgColor , $ textStyle , false );
484+ return $ this ; // /!\ Important
485+ }
486+
487+ /**
488+ * @param string $text
489+ * @param string $textColor
490+ * @param string $bgColor
491+ * @param string $textStyle
492+ * @param bool $autoDelWaitingMsg
493+ * @return $this
494+ */
455495 public function print ($ text , $ textColor = 'green ' , $ bgColor = false , $ textStyle = false , $ autoDelWaitingMsg = true )
456496 {
457497 if ($ autoDelWaitingMsg ) {
@@ -465,14 +505,31 @@ public function print($text, $textColor = 'green', $bgColor = false, $textStyle
465505 * - Si $autoDelWaitingMsg === false
466506 */
467507 $ this ->EOL (1 , false , false , false , false );
468- return $ this ->_e ($ text , $ textColor , $ bgColor , $ textStyle , false );
508+ $ this ->_e ($ text , $ textColor , $ bgColor , $ textStyle , false );
509+ return $ this ; // /!\ Important
469510 }
470511
512+ /**
513+ * @param string $text
514+ * @param string $textColor
515+ * @param string $bgColor
516+ * @param string $textStyle
517+ * @param bool $autoDelWaitingMsg
518+ * @return $this
519+ */
471520 public function debug ($ text , $ textColor = 'black ' , $ bgColor = 'white ' , $ textStyle = false , $ autoDelWaitingMsg = true )
472521 {
473522 return $ this ->print ($ text , $ textColor , $ bgColor , $ textStyle , $ autoDelWaitingMsg );
474523 }
475524
525+ /**
526+ * @param string|Exception $text
527+ * @param string $textColor
528+ * @param string $bgColor
529+ * @param string $textStyle
530+ * @param bool $autoDelWaitingMsg
531+ * @return $this
532+ */
476533 public function error ($ text , $ textColor = 'red ' , $ bgColor = false , $ textStyle = false , $ autoDelWaitingMsg = true )
477534 {
478535 if ($ autoDelWaitingMsg ) {
@@ -486,33 +543,69 @@ public function error($text, $textColor = 'red', $bgColor = false, $textStyle =
486543 * - Si $autoDelWaitingMsg === false
487544 */
488545 $ this ->EOL (1 , false , false , false , false );
489- return $ this ->_e ($ text , $ textColor , $ bgColor , $ textStyle , false );
546+
547+ if ($ text instanceof \Exception) {
548+ $ this ->throw ($ text , false , false );
549+ }
550+ else {
551+ $ this ->_e ($ text , $ textColor , $ bgColor , $ textStyle , false );
552+ }
553+
554+ return $ this ; // /!\ Important
490555 }
491556
492- public function throw (\Exception $ exception )
557+ /**
558+ * @param Exception $exception
559+ * @param bool $throwUnknownException
560+ * @param bool $exitAfterProcess
561+ * @return $this
562+ */
563+ public function throw (\Exception $ exception , $ throwUnknownException = true , $ exitAfterProcess = false )
493564 {
494- if ($ exception instanceof E \Message) {
495- return $ this ->error ($ exception ->getMessage (), 'orange ' );
565+ if ($ exception instanceof E \Message)
566+ {
567+ $ codeColors = array (
568+ E_USER_ERROR => 'red ' ,
569+ E_USER_WARNING => 'orange ' ,
570+ E_USER_NOTICE => 'blue ' ,
571+ );
496572 }
497573 else
498574 {
499- switch ($ exception ->getCode ())
575+ $ codeColors = array (
576+ E_USER_ERROR => 'red ' ,
577+ E_USER_WARNING => 'red ' ,
578+ E_USER_NOTICE => 'orange ' ,
579+ );
580+ }
581+
582+ $ eCode = $ exception ->getCode ();
583+ $ eMessage = $ exception ->getMessage ();
584+
585+ switch ($ exception ->getCode ())
586+ {
587+ case E_USER_ERROR :
588+ case E_USER_WARNING :
589+ case E_USER_NOTICE : {
590+ $ this ->error ($ eMessage , $ codeColors [$ eCode ]);
591+ break ;
592+ }
593+ default :
500594 {
501- case E_USER_ERROR : {
502- $ this ->error ($ exception ->getMessage (), 'red ' );
503- exit ;
504- }
505- case E_USER_WARNING : {
506- return $ this ->error ($ exception ->getMessage (), 'red ' );
507- }
508- case E_USER_NOTICE : {
509- return $ this ->error ($ exception ->getMessage (), 'orange ' );
510- }
511- default : {
595+ if ($ throwUnknownException ) {
512596 throw $ exception ;
513597 }
598+ else {
599+ $ this ->error ($ eMessage , 'red ' );
600+ }
514601 }
515602 }
603+
604+ if ($ exitAfterProcess ) {
605+ exit ;
606+ }
607+
608+ return $ this ;
516609 }
517610
518611 public function __get ($ name )
0 commit comments