1919use Inhere \Console \Contract \OutputInterface ;
2020use Inhere \Console \Concern \ApplicationHelpTrait ;
2121use Inhere \Console \Concern \InputOutputAwareTrait ;
22- use Inhere \Console \Concern \SimpleEventTrait ;
22+ use Inhere \Console \Concern \SimpleEventAwareTrait ;
2323use InvalidArgumentException ;
2424use Throwable ;
2525use Toolkit \Cli \Style ;
@@ -48,7 +48,7 @@ abstract class AbstractApplication implements ApplicationInterface
4848 use ApplicationHelpTrait;
4949 use InputOutputAwareTrait;
5050 use StyledOutputAwareTrait;
51- use SimpleEventTrait ;
51+ use SimpleEventAwareTrait ;
5252
5353 /** @var array */
5454 protected static $ internalCommands = [
@@ -222,21 +222,21 @@ public function run(bool $exit = true)
222222 }
223223
224224 // call 'onBeforeRun' service, if it is registered.
225- $ this ->fire (self ::ON_BEFORE_RUN , $ this );
225+ $ this ->fire (ConsoleEvent ::ON_BEFORE_RUN , $ this );
226226 $ this ->beforeRun ();
227227
228228 // do run ...
229229 $ result = $ this ->dispatch ($ command );
230230 } catch (Throwable $ e ) {
231- $ this ->fire (self ::ON_RUN_ERROR , $ e , $ this );
231+ $ this ->fire (ConsoleEvent ::ON_RUN_ERROR , $ e , $ this );
232232 $ result = $ e ->getCode () === 0 ? $ e ->getLine () : $ e ->getCode ();
233233 $ this ->handleException ($ e );
234234 }
235235
236236 $ this ->stats ['endTime ' ] = microtime (true );
237237
238238 // call 'onAfterRun' service, if it is registered.
239- $ this ->fire (self ::ON_AFTER_RUN , $ this );
239+ $ this ->fire (ConsoleEvent ::ON_AFTER_RUN , $ this );
240240 $ this ->afterRun ();
241241
242242 if ($ exit ) {
@@ -559,6 +559,18 @@ public function isStrictMode(): bool
559559 return (bool )$ this ->config ['strictMode ' ];
560560 }
561561
562+ /**
563+ * check is given verbose level
564+ *
565+ * @param int $level
566+ *
567+ * @return bool
568+ */
569+ public function isDebug (int $ level = Console::VERB_DEBUG ): bool
570+ {
571+ return $ level <= $ this ->getVerbLevel ();
572+ }
573+
562574 /**
563575 * get current debug level value
564576 *
@@ -572,7 +584,7 @@ public function getVerbLevel(): int
572584 }
573585
574586 /**
575- * is profile
587+ * is open profile
576588 *
577589 * @return boolean
578590 */
@@ -585,7 +597,7 @@ public function isProfile(): bool
585597 }
586598
587599 /**
588- * is interactive env
600+ * is open interactive env
589601 *
590602 * @return bool
591603 */
0 commit comments