88
99namespace Inhere \Console ;
1010
11- use Inhere \Console \BuiltIn \ErrorHandler ;
11+ use Inhere \Console \Component \ErrorHandler ;
1212use Inhere \Console \Face \ApplicationInterface ;
1313use Inhere \Console \Face \CommandInterface ;
1414use Inhere \Console \Face \ErrorHandlerInterface ;
1818use Inhere \Console \IO \OutputInterface ;
1919use Inhere \Console \Traits \InputOutputAwareTrait ;
2020use Inhere \Console \Traits \SimpleEventTrait ;
21- use Inhere \Console \Components \Style \Style ;
22- use Inhere \Console \Utils \FormatUtil ;
23- use Inhere \Console \Utils \Helper ;
21+ use Inhere \Console \Component \Style \Style ;
22+ use Inhere \Console \Util \FormatUtil ;
23+ use Inhere \Console \Util \Helper ;
2424
2525/**
2626 * Class AbstractApplication
@@ -158,8 +158,9 @@ protected function beforeRun()
158158 }
159159
160160 /**
161- * run app
161+ * run application
162162 * @param bool $exit
163+ * @return int|mixed
163164 * @throws \InvalidArgumentException
164165 */
165166 public function run (bool $ exit = true )
@@ -175,10 +176,10 @@ public function run(bool $exit = true)
175176
176177 // do run ...
177178 try {
178- $ returnCode = $ this ->dispatch ($ command );
179+ $ result = $ this ->dispatch ($ command );
179180 } catch (\Throwable $ e ) {
180181 $ this ->fire (self ::ON_RUN_ERROR , $ e , $ this );
181- $ returnCode = $ e ->getCode () === 0 ? $ e ->getLine () : $ e ->getCode ();
182+ $ result = $ e ->getCode () === 0 ? $ e ->getLine () : $ e ->getCode ();
182183 $ this ->handleException ($ e );
183184 }
184185
@@ -189,8 +190,10 @@ public function run(bool $exit = true)
189190 $ this ->afterRun ();
190191
191192 if ($ exit ) {
192- $ this ->stop (( int ) $ returnCode );
193+ $ this ->stop (\is_int ( $ result ) ? $ result : 0 );
193194 }
195+
196+ return $ result ;
194197 }
195198
196199 /**
0 commit comments