19
19
use Inhere \Console \Contract \OutputInterface ;
20
20
use Inhere \Console \Concern \ApplicationHelpTrait ;
21
21
use Inhere \Console \Concern \InputOutputAwareTrait ;
22
- use Inhere \Console \Concern \SimpleEventTrait ;
22
+ use Inhere \Console \Concern \SimpleEventAwareTrait ;
23
23
use InvalidArgumentException ;
24
24
use Throwable ;
25
25
use Toolkit \Cli \Style ;
@@ -48,7 +48,7 @@ abstract class AbstractApplication implements ApplicationInterface
48
48
use ApplicationHelpTrait;
49
49
use InputOutputAwareTrait;
50
50
use StyledOutputAwareTrait;
51
- use SimpleEventTrait ;
51
+ use SimpleEventAwareTrait ;
52
52
53
53
/** @var array */
54
54
protected static $ internalCommands = [
@@ -222,21 +222,21 @@ public function run(bool $exit = true)
222
222
}
223
223
224
224
// call 'onBeforeRun' service, if it is registered.
225
- $ this ->fire (self ::ON_BEFORE_RUN , $ this );
225
+ $ this ->fire (ConsoleEvent ::ON_BEFORE_RUN , $ this );
226
226
$ this ->beforeRun ();
227
227
228
228
// do run ...
229
229
$ result = $ this ->dispatch ($ command );
230
230
} catch (Throwable $ e ) {
231
- $ this ->fire (self ::ON_RUN_ERROR , $ e , $ this );
231
+ $ this ->fire (ConsoleEvent ::ON_RUN_ERROR , $ e , $ this );
232
232
$ result = $ e ->getCode () === 0 ? $ e ->getLine () : $ e ->getCode ();
233
233
$ this ->handleException ($ e );
234
234
}
235
235
236
236
$ this ->stats ['endTime ' ] = microtime (true );
237
237
238
238
// call 'onAfterRun' service, if it is registered.
239
- $ this ->fire (self ::ON_AFTER_RUN , $ this );
239
+ $ this ->fire (ConsoleEvent ::ON_AFTER_RUN , $ this );
240
240
$ this ->afterRun ();
241
241
242
242
if ($ exit ) {
@@ -559,6 +559,18 @@ public function isStrictMode(): bool
559
559
return (bool )$ this ->config ['strictMode ' ];
560
560
}
561
561
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
+
562
574
/**
563
575
* get current debug level value
564
576
*
@@ -572,7 +584,7 @@ public function getVerbLevel(): int
572
584
}
573
585
574
586
/**
575
- * is profile
587
+ * is open profile
576
588
*
577
589
* @return boolean
578
590
*/
@@ -585,7 +597,7 @@ public function isProfile(): bool
585
597
}
586
598
587
599
/**
588
- * is interactive env
600
+ * is open interactive env
589
601
*
590
602
* @return bool
591
603
*/
0 commit comments