1313/**
1414 * Class Show
1515 * show formatted message text
16- *
1716 * @package Inhere\Console\Utils
18- *
1917 * @method static int info($messages, $quit = false)
2018 * @method static int note($messages, $quit = false)
2119 * @method static int notice($messages, $quit = false)
2422 * @method static int warning($messages, $quit = false)
2523 * @method static int danger($messages, $quit = false)
2624 * @method static int error($messages, $quit = false)
27- *
2825 * @method static int liteInfo($messages, $quit = false)
2926 * @method static int liteNote($messages, $quit = false)
3027 * @method static int liteNotice($messages, $quit = false)
@@ -277,7 +274,6 @@ public static function section($title, $body, array $opts = [])
277274
278275 /**
279276 * Show a list
280- *
281277 * ```
282278 * $title = 'list title';
283279 * $data = [
@@ -316,7 +312,6 @@ public static function aList($data, $title = null, array $opts = [])
316312
317313 /**
318314 * Show multi list
319- *
320315 * ```
321316 * [
322317 * 'list1 title' => [
@@ -330,7 +325,6 @@ public static function aList($data, $title = null, array $opts = [])
330325 * ... ...
331326 * ]
332327 * ```
333- *
334328 * @param array $data
335329 * @param array $opts
336330 */
@@ -353,15 +347,11 @@ public static function mList(array $data, array $opts = [])
353347
354348 /**
355349 * Show console help message
356- *
357350 * @param array $config The config data
358- *
359351 * There are config structure. you can setting some or ignore some. will only render it when value is not empty.
360- *
361352 * [
362353 * description string The description text. e.g 'Composer version 1.3.2'
363354 * usage string The usage message text. e.g 'command [options] [arguments]'
364- *
365355 * commands array|string The command list. e.g:
366356 * [
367357 * // command => description
@@ -382,7 +372,6 @@ public static function mList(array $data, array $opts = [])
382372 * '-h, --help' => 'Display this help message'
383373 * ... ...
384374 * ]
385- *
386375 * examples array|string The command usage example. e.g 'php server.php {start|reload|restart|stop} [-d]'
387376 * ]
388377 * @param bool $showAfterQuit Show help after quit
@@ -548,6 +537,7 @@ public static function panel($data, $title = 'Information Panel', array $opts =
548537 }
549538
550539 unset($ panelData );
540+
551541 return 0 ;
552542 }
553543
@@ -557,7 +547,6 @@ public static function panel($data, $title = 'Information Panel', array $opts =
557547 * @param string $title
558548 * @param array $opts
559549 * @example
560- *
561550 * ```
562551 * // like from database query's data.
563552 * $data = [
@@ -566,14 +555,12 @@ public static function panel($data, $title = 'Information Panel', array $opts =
566555 * ... ...
567556 * ];
568557 * Show::table($data, 'a table');
569- *
570558 * // use custom head
571559 * $data = [
572560 * [ value1, value2, value3, ... ], // first row
573561 * [ value4, value5, value6, ... ], // second row
574562 * ... ...
575563 * ];
576- *
577564 * $opts = [
578565 * 'showBorder' => true,
579566 * 'tHead' => [col1, col2, col3, ...]
@@ -751,7 +738,6 @@ public static function progressTxt($total, $msg, $doneMsg = '')
751738
752739 /**
753740 * a simple progress bar by 'yield'
754- *
755741 * ```php
756742 * $i = 0;
757743 * $total = 120;
@@ -760,14 +746,12 @@ public static function progressTxt($total, $msg, $doneMsg = '')
760746 * 'doneChar' => '#'
761747 * ]);
762748 * echo "progress:\n";
763- *
764749 * while ($i <= $total) {
765750 * $bar->send($i);
766751 * usleep(50000);
767752 * $i++;
768753 * }
769754 * ```
770- *
771755 * @param int $total
772756 * @param array $opts
773757 * @internal int $current
@@ -814,6 +798,35 @@ public static function progressBar($total, array $opts = [])
814798 yield false ;
815799 }
816800
801+ /**
802+ * create ProgressBar
803+ *
804+ * ```php
805+ * $max = 200;
806+ * $bar = Show::createProgressBar($max);
807+ * while ($i <= $total) {
808+ * $bar->advance();
809+ * usleep(50000);
810+ * $i++;
811+ * }
812+ * $bar->finish();
813+ * ```
814+ *
815+ * @param int $max
816+ * @param bool $start
817+ * @return ProgressBar
818+ */
819+ public static function createProgressBar ($ max = 0 , $ start = true )
820+ {
821+ $ bar = new ProgressBar (null , $ max );
822+
823+ if ($ start ) {
824+ $ bar ->start ();
825+ }
826+
827+ return $ bar ;
828+ }
829+
817830/////////////////////////////////////////////////////////////////
818831/// Helper Method
819832/////////////////////////////////////////////////////////////////
0 commit comments