1010
1111use ErrorException ;
1212use Inhere \Console \Component \ErrorHandler ;
13+ use Inhere \Console \Component \Formatter \Title ;
1314use Inhere \Console \Concern \StyledOutputAwareTrait ;
1415use Inhere \Console \Contract \ApplicationInterface ;
1516use Inhere \Console \Contract \ErrorHandlerInterface ;
3435use function header ;
3536use function in_array ;
3637use function is_int ;
38+ use function json_encode ;
3739use function memory_get_usage ;
3840use function microtime ;
3941use function register_shutdown_function ;
@@ -90,6 +92,7 @@ abstract class AbstractApplication implements ApplicationInterface
9092 'publishAt ' => '2017.03.24 ' ,
9193 'updateAt ' => '2019.01.01 ' ,
9294 'rootPath ' => '' ,
95+ 'ishellName ' => '' , // name prefix on i-shell env.
9396 'strictMode ' => false ,
9497 'hideRootPath ' => true ,
9598 // global options
@@ -412,7 +415,9 @@ protected function startInteractiveShell(): void
412415 $ in = $ this ->input ;
413416 $ out = $ this ->output ;
414417
415- $ out ->colored ("Will start interactive shell for run application " );
418+ $ out ->title ("Welcome interactive shell for run application " , [
419+ 'titlePos ' => Title::POS_MIDDLE ,
420+ ]);
416421
417422 if (!($ hasPcntl = ProcessUtil::hasPcntl ())) {
418423 $ this ->debugf ('php is not enable "pcntl" extension, cannot listen CTRL+C signal ' );
@@ -426,14 +431,19 @@ protected function startInteractiveShell(): void
426431 });
427432 }
428433
434+ $ prefix = $ this ->getParam ('ishellName ' ) ?: $ this ->getName ();
435+ if (!$ prefix ) {
436+ $ prefix = 'CMD ' ;
437+ }
438+
429439 $ exitKeys = [
430440 'q ' => 1 ,
431441 'quit ' => 1 ,
432442 'exit ' => 1 ,
433443 ];
434444
435445 while (true ) {
436- $ line = Interact::readln (' <comment>CMD ></comment> ' );
446+ $ line = Interact::readln (" <comment> $ prefix ></comment> " );
437447 if (strlen ($ line ) < 5 ) {
438448 if (isset ($ exitKeys [$ line ])) {
439449 break ;
@@ -451,9 +461,11 @@ protected function startInteractiveShell(): void
451461 }
452462
453463 $ args = LineParser::parseIt ($ line );
464+ $ this ->debugf ('input line: %s, parsed args: %s ' , $ line , json_encode ($ args ));
454465
455466 // reload and parse args
456467 $ in ->parse ($ args );
468+ $ in ->setFullScript ($ line );
457469
458470 // \vdump($in);
459471 $ this ->run (false );
0 commit comments