@@ -1,23 +1,23 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | 5 | console::resetDefaults(); |
| 6 | 6 | |
| 7 | -Console::log(' ' . Console::text('Basic sample', 'white', 'underlined')); |
|
| 7 | +Console::log(' '.Console::text('Basic sample', 'white', 'underlined')); |
|
| 8 | 8 | Console::log(); |
| 9 | 9 | |
| 10 | 10 | $rowHeaders = ['Index' => 10, 'Item' => 25, 'Description' => 50]; |
| 11 | 11 | $rows = [ |
| 12 | - ['foo', 'some text for foo'], |
|
| 13 | - ['bar', 'some text for bar'], |
|
| 14 | - ['foobar', 'some text for foobar'] |
|
| 12 | + ['foo', 'some text for foo'], |
|
| 13 | + ['bar', 'some text for bar'], |
|
| 14 | + ['foobar', 'some text for foobar'] |
|
| 15 | 15 | ]; |
| 16 | 16 | Console::log(Console::tableSeparator($rowHeaders)); |
| 17 | 17 | Console::log(Console::tableRow($rowHeaders)); |
| 18 | 18 | Console::log(Console::tableRowSeparator($rowHeaders)); |
| 19 | 19 | |
| 20 | -foreach ($rows as $key => $value){ |
|
| 20 | +foreach ($rows as $key => $value) { |
|
| 21 | 21 | Console::log(Console::tableRow([ |
| 22 | 22 | $key => 10, |
| 23 | 23 | $rows[$key][0] => 25, |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | // ------------------------------- |
| 35 | 35 | // ------ ADVANCED SAMPLE -------- |
| 36 | 36 | // ------------------------------- |
| 37 | -Console::log(' ' . Console::text('Advanced sample', 'white', 'underlined')); |
|
| 37 | +Console::log(' '.Console::text('Advanced sample', 'white', 'underlined')); |
|
| 38 | 38 | Console::log(); |
| 39 | 39 | |
| 40 | 40 | $rowHeaders = [ |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | ]; |
| 45 | 45 | $rows = [ |
| 46 | 46 | [ |
| 47 | - Console::text('foo', 'white'), |
|
| 47 | + Console::text('foo', 'white'), |
|
| 48 | 48 | Console::text('some centered text red for foo', 'red') |
| 49 | 49 | ], |
| 50 | 50 | [ |
| 51 | - Console::text('bar', 'white'), |
|
| 52 | - Console::text( 'some centered text green for bar', 'green') |
|
| 51 | + Console::text('bar', 'white'), |
|
| 52 | + Console::text('some centered text green for bar', 'green') |
|
| 53 | 53 | ], |
| 54 | 54 | [ |
| 55 | 55 | Console::text('foobar', 'white'), |
| 56 | - 'some text with unicode ✓ ' .Console::text('on BLUE here', 'white', 'blue') |
|
| 56 | + 'some text with unicode ✓ '.Console::text('on BLUE here', 'white', 'blue') |
|
| 57 | 57 | ] |
| 58 | 58 | ]; |
| 59 | 59 | |
@@ -66,24 +66,24 @@ discard block |
||
| 66 | 66 | Console::$tableCellPadding = ' '; // increase cell padding to 2 white chars (default is 1) |
| 67 | 67 | |
| 68 | 68 | // table start |
| 69 | -Console::log(Console::tableSeparator($rowHeaders)); // top line |----------------------- ... |
|
| 70 | -Console::log(Console::tableRow($rowHeaders)); // columns headers | foo | bar |--- ... |
|
| 69 | +Console::log(Console::tableSeparator($rowHeaders)); // top line |----------------------- ... |
|
| 70 | +Console::log(Console::tableRow($rowHeaders)); // columns headers | foo | bar |--- ... |
|
| 71 | 71 | Console::log(Console::tableRowSeparator($rowHeaders)); // saparator |---------|---------|--- ... |
| 72 | -Console::log(Console::tableRowEmpty($rowHeaders)); // empty row | | | ... |
|
| 72 | +Console::log(Console::tableRowEmpty($rowHeaders)); // empty row | | | ... |
|
| 73 | 73 | |
| 74 | 74 | // tables rows |
| 75 | -foreach ($rows as $key => $value){ |
|
| 75 | +foreach ($rows as $key => $value) { |
|
| 76 | 76 | |
| 77 | 77 | Console::log( |
| 78 | - Console::TableRowStart(). // start row with separator. Then, each cell will end with a separator |
|
| 79 | - Console::TableRowCell($key, 10). //no align => default is left |
|
| 80 | - Console::TableRowCell($rows[$key][0] , 25, Console::ALIGN_RIGHT). //set align right |
|
| 81 | - Console::TableRowCell($rows[$key][1] , 50, Console::ALIGN_CENTER) //set align center |
|
| 78 | + Console::TableRowStart().// start row with separator. Then, each cell will end with a separator |
|
| 79 | + Console::TableRowCell($key, 10).//no align => default is left |
|
| 80 | + Console::TableRowCell($rows[$key][0], 25, Console::ALIGN_RIGHT).//set align right |
|
| 81 | + Console::TableRowCell($rows[$key][1], 50, Console::ALIGN_CENTER) //set align center |
|
| 82 | 82 | ); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // table end |
| 86 | -Console::log(Console::tableRowEmpty($rowHeaders)); // empty row | | | ... |
|
| 86 | +Console::log(Console::tableRowEmpty($rowHeaders)); // empty row | | | ... |
|
| 87 | 87 | Console::log(Console::tableSeparator($rowHeaders)); // saparator |----------------------- ... |
| 88 | 88 | console::resetDefaults(); |
| 89 | 89 | |
@@ -91,38 +91,38 @@ discard block |
||
| 91 | 91 | // ------ ANOTHER STYLE --------- |
| 92 | 92 | // ------------------------------- |
| 93 | 93 | Console::log(); |
| 94 | -Console::log(' ' . Console::text('Another style sample', 'white', 'underlined')); |
|
| 94 | +Console::log(' '.Console::text('Another style sample', 'white', 'underlined')); |
|
| 95 | 95 | Console::log(); |
| 96 | 96 | |
| 97 | 97 | $rowHeaders = [ |
| 98 | - Console::text('Item', 'darkgray') => 10, |
|
| 99 | - Console::text('Status', 'darkgray') => 12, |
|
| 100 | - Console::text('Description', 'darkgray') => 25 |
|
| 98 | + Console::text('Item', 'darkgray') => 10, |
|
| 99 | + Console::text('Status', 'darkgray') => 12, |
|
| 100 | + Console::text('Description', 'darkgray') => 25 |
|
| 101 | 101 | ]; |
| 102 | 102 | $rows = [ |
| 103 | - [Console::text('foo', 'white'), Console::text(' ONLINE ', 'white', 'green') , Console::text('some text for foo', 'white')], |
|
| 104 | - [Console::text('bar', 'white'), Console::text(' ONLINE ', 'white', 'green') , Console::text('some text for bar', 'white')], |
|
| 105 | - [Console::text('foobar ', 'white'), Console::text(' OFFLINE ', 'white', 'red') , Console::text('some text for foobar', 'white')] |
|
| 103 | + [Console::text('foo', 'white'), Console::text(' ONLINE ', 'white', 'green'), Console::text('some text for foo', 'white')], |
|
| 104 | + [Console::text('bar', 'white'), Console::text(' ONLINE ', 'white', 'green'), Console::text('some text for bar', 'white')], |
|
| 105 | + [Console::text('foobar ', 'white'), Console::text(' OFFLINE ', 'white', 'red'), Console::text('some text for foobar', 'white')] |
|
| 106 | 106 | ]; |
| 107 | 107 | |
| 108 | -Console::$horizontalSeparator = '-'; // change the horizontal separator |
|
| 109 | -Console::$tableCellPadding = ''; // no padding |
|
| 110 | -Console::$verticalInnerSeparator = ' '; // blank separator |
|
| 111 | - Console::$verticalSeparator = ' '; // no top left/right separator except a margin.. |
|
| 108 | +Console::$horizontalSeparator = '-'; // change the horizontal separator |
|
| 109 | +Console::$tableCellPadding = ''; // no padding |
|
| 110 | +Console::$verticalInnerSeparator = ' '; // blank separator |
|
| 111 | + Console::$verticalSeparator = ' '; // no top left/right separator except a margin.. |
|
| 112 | 112 | // Console::$verticalHeaderSeparator = ''; // no top left/right separator (not needed) |
| 113 | 113 | |
| 114 | 114 | // table start |
| 115 | 115 | Console::log(Console::tableRowSeparator($rowHeaders, 'drakgray')); // saparator --------- --------- --- |
| 116 | -Console::log(Console::tableRow($rowHeaders, 'drakgray')); // columns headers foo bar f... |
|
| 116 | +Console::log(Console::tableRow($rowHeaders, 'drakgray')); // columns headers foo bar f... |
|
| 117 | 117 | Console::log(Console::tableRowSeparator($rowHeaders, 'drakgray')); // saparator --------- --------- --- |
| 118 | 118 | |
| 119 | 119 | // tables rows |
| 120 | -foreach ($rows as $row){ |
|
| 120 | +foreach ($rows as $row) { |
|
| 121 | 121 | Console::log( |
| 122 | - Console::TableRowStart(). // start row with separator. Then, each cell will end with a separator |
|
| 123 | - Console::TableRowCell($row[0] , 10). // keep left alignment |
|
| 124 | - Console::TableRowCell($row[1] , 12, Console::ALIGN_CENTER). // align center |
|
| 125 | - Console::TableRowCell($row[2] , 25) // keep left alignment |
|
| 122 | + Console::TableRowStart().// start row with separator. Then, each cell will end with a separator |
|
| 123 | + Console::TableRowCell($row[0], 10).// keep left alignment |
|
| 124 | + Console::TableRowCell($row[1], 12, Console::ALIGN_CENTER).// align center |
|
| 125 | + Console::TableRowCell($row[2], 25) // keep left alignment |
|
| 126 | 126 | ); |
| 127 | 127 | } |
| 128 | 128 | // table end |
@@ -1,29 +1,29 @@ |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | -Console::log(' '. Console::text('Overview:', 'underlined', 'bold')); |
|
| 6 | -Console::log(" - Use " . Console::text("int|bool ", 'blue') . Console::text("Console::askInt()", 'lightblue', 'underlined') . " to ask user to enter a number in the console."); |
|
| 5 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
| 6 | +Console::log(" - Use ".Console::text("int|bool ", 'blue').Console::text("Console::askInt()", 'lightblue', 'underlined')." to ask user to enter a number in the console."); |
|
| 7 | 7 | Console::log(); |
| 8 | -Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
|
| 9 | -Console::log(" - The method returns " . Console::text("int", 'blue') . " value or " . Console::text("false", 'blue'). " if the entered value is not a valid int number."); |
|
| 8 | +Console::log(' '.Console::text('Tips:', 'underlined', 'bold')); |
|
| 9 | +Console::log(" - The method returns ".Console::text("int", 'blue')." value or ".Console::text("false", 'blue')." if the entered value is not a valid int number."); |
|
| 10 | 10 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
| 11 | -Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
|
| 12 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 11 | +Console::log(' with '.Console::text("Console::text()", 'lightblue', 'underlined'). |
|
| 12 | + ' and '.Console::text("Console::log()", 'lightblue', 'underlined').' methods.'); |
|
| 13 | 13 | Console::log(); |
| 14 | -Console::log(' '. Console::text('Usage:', 'underlined', 'bold')); |
|
| 15 | -Console::log(' ' . Console::text("\$value = Console::askInt('Please enter a number > ');", 'lightmagenta')); |
|
| 16 | -Console::log(' ' . Console::text("if (\$value !== false) {", 'lightmagenta')); |
|
| 17 | -Console::log(' ' . Console::text("// Do something with \$value", 'green')); |
|
| 14 | +Console::log(' '.Console::text('Usage:', 'underlined', 'bold')); |
|
| 15 | +Console::log(' '.Console::text("\$value = Console::askInt('Please enter a number > ');", 'lightmagenta')); |
|
| 16 | +Console::log(' '.Console::text("if (\$value !== false) {", 'lightmagenta')); |
|
| 17 | +Console::log(' '.Console::text("// Do something with \$value", 'green')); |
|
| 18 | 18 | Console::log(); |
| 19 | -Console::log(' '. Console::text('Sample:', 'underlined', 'bold')); |
|
| 19 | +Console::log(' '.Console::text('Sample:', 'underlined', 'bold')); |
|
| 20 | 20 | |
| 21 | 21 | // ----------------- |
| 22 | 22 | // sample start here |
| 23 | 23 | // ----------------- |
| 24 | 24 | $value = Console::askInt(' Please enter a number > '); |
| 25 | -if ($value !== false){ |
|
| 26 | - Console::log(' => The value you entered is [' . Console::text($value, 'yellow') . ']'); |
|
| 25 | +if ($value !== false) { |
|
| 26 | + Console::log(' => The value you entered is ['.Console::text($value, 'yellow').']'); |
|
| 27 | 27 | } else { |
| 28 | 28 | Console::log(Console::text(' Error:', 'red')); |
| 29 | 29 | Console::log(Console::text(' => the value you entered is not a valid number.', 'red')); |
@@ -1,30 +1,30 @@ |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | -Console::log(' '. Console::text('Overview:', 'underlined', 'bold')); |
|
| 6 | -Console::log(" - Use " . Console::text("string ", 'blue'). Console::text("Console::pad()", 'lightblue', 'underlined') . "to get a text with given padding."); |
|
| 7 | -Console::log(" - The method is equivalent to php " . Console::text("str_pad()", 'lightblue', 'underlined'). " method, except that it handles not printable ANSI chars."); |
|
| 5 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
| 6 | +Console::log(" - Use ".Console::text("string ", 'blue').Console::text("Console::pad()", 'lightblue', 'underlined')."to get a text with given padding."); |
|
| 7 | +Console::log(" - The method is equivalent to php ".Console::text("str_pad()", 'lightblue', 'underlined')." method, except that it handles not printable ANSI chars."); |
|
| 8 | 8 | Console::log(); |
| 9 | -Console::log(' '. Console::text('Sample:', 'underlined', 'bold')); |
|
| 9 | +Console::log(' '.Console::text('Sample:', 'underlined', 'bold')); |
|
| 10 | 10 | |
| 11 | 11 | // ----------------- |
| 12 | 12 | // sample start here |
| 13 | 13 | // ----------------- |
| 14 | 14 | Console::log(); |
| 15 | -Console::log(' '. Console::text(' 1) Using ') . Console::text('php str_pad()', 'lightblue', 'underlined')); |
|
| 15 | +Console::log(' '.Console::text(' 1) Using ').Console::text('php str_pad()', 'lightblue', 'underlined')); |
|
| 16 | 16 | Console::log(); |
| 17 | 17 | Console::log(str_pad(' I am normal inside str_pad() {padLength:100, padString:\'*\'}', 100, '*')); |
| 18 | 18 | Console::log(str_pad(Console::text(' I am colorized with ::text() inside str_pad() {padLength:100, padString:\'*\'}', 'lightcyan'), 100, '*')); |
| 19 | 19 | Console::log(); |
| 20 | -Console::log(' '. Console::text(' => you should\'see what you expect. I guess second text has less than 100 chars... ', 'white', 'red')); |
|
| 20 | +Console::log(' '.Console::text(' => you should\'see what you expect. I guess second text has less than 100 chars... ', 'white', 'red')); |
|
| 21 | 21 | Console::log(); |
| 22 | 22 | Console::log(); |
| 23 | -Console::log(' '. Console::text(' 2) Using ') . Console::text('Console::pad()', 'lightblue', 'underlined')); |
|
| 23 | +Console::log(' '.Console::text(' 2) Using ').Console::text('Console::pad()', 'lightblue', 'underlined')); |
|
| 24 | 24 | Console::log(); |
| 25 | 25 | Console::log(Console::pad(' I am normal inside ::pad() {padLength:100, padString:\'*\'}', 100, '*')); |
| 26 | 26 | Console::log(Console::pad(Console::text(' I am colorized with ::text() inside ::pad() {padLength:100, padString:\'*\'}', 'lightcyan'), 100, '*')); |
| 27 | 27 | Console::log(); |
| 28 | -Console::log(' '. Console::text(' => should be OK ', 'white', 'green')); |
|
| 28 | +Console::log(' '.Console::text(' => should be OK ', 'white', 'green')); |
|
| 29 | 29 | |
| 30 | 30 | ?> |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | 5 | // *open* new window |
| 6 | 6 | Console::newWindow(); |
| 7 | 7 | |
| 8 | -declare(ticks = 1); // Allow posix signal handling |
|
| 8 | +declare(ticks=1); // Allow posix signal handling |
|
| 9 | 9 | pcntl_async_signals(true); |
| 10 | -pcntl_signal(SIGINT,"shutdown"); |
|
| 11 | -register_shutdown_function("shutdown"); // Handle END of script |
|
| 10 | +pcntl_signal(SIGINT, "shutdown"); |
|
| 11 | +register_shutdown_function("shutdown"); // Handle END of script |
|
| 12 | 12 | |
| 13 | 13 | splash(); |
| 14 | 14 | |
| 15 | -function shutdown(){ |
|
| 15 | +function shutdown() { |
|
| 16 | 16 | // echo "\033c"; // Clear terminal |
| 17 | 17 | // echo PHP_EOL; // New line |
| 18 | 18 | //Console::log(); |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | $cols = Console::getColumns(); |
| 32 | 32 | $middle = round($lines/2); |
| 33 | 33 | |
| 34 | - for ($i= 1; $i <= $lines ; $i++){ |
|
| 35 | - switch($i){ |
|
| 36 | - case $middle -1: Console::log(Console::pad("Stand With Ukraine <3", $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); break; |
|
| 37 | - case $middle: Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); break; |
|
| 38 | - case $middle +1: Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); break; |
|
| 39 | - case $middle +2: Console::log(Console::pad('Slava Ukraini', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); break; |
|
| 40 | - case $lines: Console::print(Console::pad(' Wait a few seconds or hint Ctrl+C', $cols , ' ', STR_PAD_LEFT), 'blue', 'yellow'); break; // no new line here |
|
| 34 | + for ($i = 1; $i <= $lines; $i++) { |
|
| 35 | + switch ($i) { |
|
| 36 | + case $middle-1: Console::log(Console::pad("Stand With Ukraine <3", $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); break; |
|
| 37 | + case $middle: Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); break; |
|
| 38 | + case $middle+1: Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); break; |
|
| 39 | + case $middle+2: Console::log(Console::pad('Slava Ukraini', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); break; |
|
| 40 | + case $lines: Console::print(Console::pad(' Wait a few seconds or hint Ctrl+C', $cols, ' ', STR_PAD_LEFT), 'blue', 'yellow'); break; // no new line here |
|
| 41 | 41 | default: |
| 42 | 42 | if ($i > $middle) { |
| 43 | 43 | Console::log(Console::pad(' ', $cols), 'blue', 'yellow'); |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | 5 | Console::log(); |
| 6 | -Console::log(' '. Console::text('Overview:', 'underlined', 'bold')); |
|
| 7 | -Console::log(" - Use " . Console::text("int ", 'blue'). Console::text("Console::getLines()", 'lightblue', 'underlined') . " to get the number of lines in terminal."); |
|
| 8 | -Console::log(" - Use " . Console::text("int ", 'blue'). Console::text("Console::getColumns()", 'lightblue', 'underlined') . " to get the number of columns in terminal."); |
|
| 6 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
| 7 | +Console::log(" - Use ".Console::text("int ", 'blue').Console::text("Console::getLines()", 'lightblue', 'underlined')." to get the number of lines in terminal."); |
|
| 8 | +Console::log(" - Use ".Console::text("int ", 'blue').Console::text("Console::getColumns()", 'lightblue', 'underlined')." to get the number of columns in terminal."); |
|
| 9 | 9 | Console::log(); |
| 10 | 10 | Console::log(); |
| 11 | -Console::log(' '. Console::text('Sample:', 'underlined', 'bold')); |
|
| 11 | +Console::log(' '.Console::text('Sample:', 'underlined', 'bold')); |
|
| 12 | 12 | Console::log(); |
| 13 | 13 | |
| 14 | 14 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | 5 | // *open* new window |
@@ -10,18 +10,18 @@ discard block |
||
| 10 | 10 | $cols = Console::getColumns(); |
| 11 | 11 | $middle = round($lines/2); |
| 12 | 12 | |
| 13 | -for ($i= 1; $i <= $lines ; $i++){ |
|
| 14 | - switch($i){ |
|
| 15 | - case $middle -1: |
|
| 13 | +for ($i = 1; $i <= $lines; $i++) { |
|
| 14 | + switch ($i) { |
|
| 15 | + case $middle-1: |
|
| 16 | 16 | Console::log(Console::pad("Slava", $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); |
| 17 | 17 | break; |
| 18 | 18 | case $middle: |
| 19 | 19 | Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); |
| 20 | 20 | break; |
| 21 | - case $middle +1: |
|
| 21 | + case $middle+1: |
|
| 22 | 22 | Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); |
| 23 | 23 | break; |
| 24 | - case $middle +2: |
|
| 24 | + case $middle+2: |
|
| 25 | 25 | Console::log(Console::pad('Ukraini', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); |
| 26 | 26 | break; |
| 27 | 27 | case $lines: |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | 5 | // temporary message |
@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | // wait for a while, so we see the animation |
| 9 | 9 | sleep(3); |
| 10 | 10 | |
| 11 | -for ($i=1 ; $i<=100 ; $i++) { |
|
| 11 | +for ($i = 1; $i <= 100; $i++) { |
|
| 12 | 12 | |
| 13 | 13 | // progress message |
| 14 | - Console::overwrite(' I am a progress text... ('.Console::text($i.'%', 'green') .' completed)'); |
|
| 14 | + Console::overwrite(' I am a progress text... ('.Console::text($i.'%', 'green').' completed)'); |
|
| 15 | 15 | |
| 16 | 16 | // wait for a while, so we see the animation |
| 17 | 17 | usleep(100000); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | 5 | // get columns and lines |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | $cols = Console::getColumns(); |
| 8 | 8 | |
| 9 | 9 | // print value |
| 10 | -Console::log(' The number of lines is currently: ' .Console::text($lines, 'green')); |
|
| 11 | -Console::log(' The number of columns is currently: ' .Console::text($cols, 'green')); |
|
| 10 | +Console::log(' The number of lines is currently: '.Console::text($lines, 'green')); |
|
| 11 | +Console::log(' The number of columns is currently: '.Console::text($cols, 'green')); |
|
| 12 | 12 | Console::log(); |
| 13 | 13 | |
| 14 | 14 | // build a 'full' row |
@@ -27,19 +27,19 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function shutdown(){ |
| 30 | - // echo "\033c"; // Clear terminal |
|
| 31 | - // echo PHP_EOL; // New line |
|
| 32 | - Console::clear(); |
|
| 33 | - Console::clear(); |
|
| 34 | - Console::clear(); |
|
| 35 | - Console::clear(); |
|
| 36 | - Console::clear(); |
|
| 37 | - Console::log('SIGINT signal detected, terminate script...'); |
|
| 38 | - sleep(1); |
|
| 30 | + // echo "\033c"; // Clear terminal |
|
| 31 | + // echo PHP_EOL; // New line |
|
| 32 | + Console::clear(); |
|
| 33 | + Console::clear(); |
|
| 34 | + Console::clear(); |
|
| 35 | + Console::clear(); |
|
| 36 | + Console::clear(); |
|
| 37 | + Console::log('SIGINT signal detected, terminate script...'); |
|
| 38 | + sleep(1); |
|
| 39 | 39 | |
| 40 | - // .. |
|
| 41 | - // Console::restoreWindow(); |
|
| 42 | - exit(0); |
|
| 40 | + // .. |
|
| 41 | + // Console::restoreWindow(); |
|
| 42 | + exit(0); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function printLoader($introDelay = 75000, $printAll = true) |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
| 59 | 59 | Console::log(' '.Console::text("kristuff/mishell: A mini PHP library to build CLI app and reports", "green")); |
| 60 | 60 | Console::log(' '.Console::text('Made with ', 'green') . Console::text('♥', 'red'). |
| 61 | - Console::text(' ', 'green'). |
|
| 62 | - Console::text(" | © 2017-2024 kri157uff", "green")); |
|
| 61 | + Console::text(' ', 'green'). |
|
| 62 | + Console::text(" | © 2017-2024 kri157uff", "green")); |
|
| 63 | 63 | Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
| 64 | 64 | Console::log(); |
| 65 | 65 | usleep($introDelay * random_int(7, 11)); |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | $msg3 = Console::text(' [*]', $i==100 ? $hareColor : 'blue').Console::text(' |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 2 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | 3 | use Kristuff\Mishell\Console; |
| 4 | 4 | |
| 5 | -declare(ticks = 1); // Allow posix signal handling |
|
| 5 | +declare(ticks=1); // Allow posix signal handling |
|
| 6 | 6 | pcntl_async_signals(true); |
| 7 | -pcntl_signal(SIGINT,"shutdown"); |
|
| 8 | -register_shutdown_function("shutdown"); // Handle END of script |
|
| 7 | +pcntl_signal(SIGINT, "shutdown"); |
|
| 8 | +register_shutdown_function("shutdown"); // Handle END of script |
|
| 9 | 9 | |
| 10 | 10 | // Console::newWindow(); |
| 11 | 11 | // standWithUkraine("Stand with Ukraine <3", "Slava Ukraini"); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | askIndex(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -function shutdown(){ |
|
| 29 | +function shutdown() { |
|
| 30 | 30 | // echo "\033c"; // Clear terminal |
| 31 | 31 | // echo PHP_EOL; // New line |
| 32 | 32 | Console::clear(); |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | splash(); |
| 51 | 51 | Console::clear(); |
| 52 | 52 | Console::log(); |
| 53 | - Console::log(Console::text(" _ _ _ _ ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
| 54 | - Console::log(Console::text(" _ __ (_)__| |_ ___| | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
| 55 | - Console::log(Console::text(" | ' \| (_-< ' \/ -_) | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
| 56 | - Console::log(Console::text(" |_|_|_|_/__/_||_\___|_|_| ", 'yellow').Console::text('By ', 'yellow').Console::text("kr157uff", 'green') ); |
|
| 53 | + Console::log(Console::text(" _ _ _ _ ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green')); |
|
| 54 | + Console::log(Console::text(" _ __ (_)__| |_ ___| | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green')); |
|
| 55 | + Console::log(Console::text(" | ' \| (_-< ' \/ -_) | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green')); |
|
| 56 | + Console::log(Console::text(" |_|_|_|_/__/_||_\___|_|_| ", 'yellow').Console::text('By ', 'yellow').Console::text("kr157uff", 'green')); |
|
| 57 | 57 | Console::log(); |
| 58 | 58 | Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
| 59 | 59 | Console::log(' '.Console::text("kristuff/mishell: A mini PHP library to build CLI app and reports", "green")); |
| 60 | - Console::log(' '.Console::text('Made with ', 'green') . Console::text('♥', 'red'). |
|
| 60 | + Console::log(' '.Console::text('Made with ', 'green').Console::text('♥', 'red'). |
|
| 61 | 61 | Console::text(' ', 'green'). |
| 62 | 62 | Console::text(" | © 2017-2024 kri157uff", "green")); |
| 63 | 63 | Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
| 64 | 64 | Console::log(); |
| 65 | - usleep($introDelay * random_int(7, 11)); |
|
| 65 | + usleep($introDelay*random_int(7, 11)); |
|
| 66 | 66 | $new = Console::text("NEW", 'green', 'blink'); |
| 67 | 67 | $fullRowString = Console::pad('', Console::getColumns()); |
| 68 | - $badgeOnline = Console::text(' ONLINE ', 'yellow', 'green'). ' '; |
|
| 68 | + $badgeOnline = Console::text(' ONLINE ', 'yellow', 'green').' '; |
|
| 69 | 69 | $badgeError = Console::text(' |