@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $foregroundColor = ($bgcolor === 'black' || $bgcolor === 'default') ? 'white': 'black'; |
| 14 | 14 | Console::log(' '.Console::tableRow([ |
| 15 | 15 | $bgcolor => 15, |
| 16 | - "\\033[" . $colorValue .'m' => 15, |
|
| 16 | + "\\033[" . $colorValue .'m' => 15, |
|
| 17 | 17 | Console::text(str_pad('I am a text color={' . $foregroundColor .'} on bgcolor={' . $bgcolor .'}', 48), $foregroundColor , $bgcolor) => 51 |
| 18 | 18 | ])); |
| 19 | 19 | $i++; |
@@ -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 | $rowHeaders = ['Color name' => 15, ' ANSI Code' => 15, ' Sample output' => 51]; |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | // enum backgrounds |
| 11 | 11 | $i = 1; |
| 12 | -foreach (Console::getStyles()['backgrounds'] as $bgcolor => $colorValue ){ |
|
| 13 | - $foregroundColor = ($bgcolor === 'black' || $bgcolor === 'default') ? 'white': 'black'; |
|
| 12 | +foreach (Console::getStyles()['backgrounds'] as $bgcolor => $colorValue) { |
|
| 13 | + $foregroundColor = ($bgcolor === 'black' || $bgcolor === 'default') ? 'white' : 'black'; |
|
| 14 | 14 | Console::log(' '.Console::tableRow([ |
| 15 | 15 | $bgcolor => 15, |
| 16 | - "\\033[" . $colorValue .'m' => 15, |
|
| 17 | - Console::text(str_pad('I am a text color={' . $foregroundColor .'} on bgcolor={' . $bgcolor .'}', 48), $foregroundColor , $bgcolor) => 51 |
|
| 16 | + "\\033[".$colorValue.'m' => 15, |
|
| 17 | + Console::text(str_pad('I am a text color={'.$foregroundColor.'} on bgcolor={'.$bgcolor.'}', 48), $foregroundColor, $bgcolor) => 51 |
|
| 18 | 18 | ])); |
| 19 | 19 | $i++; |
| 20 | 20 | } |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
| 10 | 10 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
| 11 | 11 | Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
| 12 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 12 | + ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 13 | 13 | Console::log(); |
| 14 | 14 | Console::log(' '. Console::text('Usage:', 'underlined', 'bold')); |
| 15 | 15 | Console::log(' '. Console::text("\$value = Console::ask('Please enter something > ');", 'lightmagenta')); |
@@ -1,29 +1,29 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once __DIR__ .'/../vendor/autoload.php'; |
|
| 3 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 4 | 4 | use Kristuff\Mishell\Console; |
| 5 | 5 | |
| 6 | -Console::log(' '. Console::text('Overview:', 'underlined', 'bold')); |
|
| 7 | -Console::log(' '. Console::text(" - Use ") . Console::text("string ", 'blue'). Console::text("Console::ask()", 'lightblue', 'underlined') . " to ask something to user in the console."); |
|
| 6 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
| 7 | +Console::log(' '.Console::text(" - Use ").Console::text("string ", 'blue').Console::text("Console::ask()", 'lightblue', 'underlined')." to ask something to user in the console."); |
|
| 8 | 8 | Console::log(); |
| 9 | -Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
|
| 9 | +Console::log(' '.Console::text('Tips:', 'underlined', 'bold')); |
|
| 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::ask('Please enter something > ');", 'lightmagenta')); |
|
| 16 | -Console::log(' '. Console::text("// or", 'green')); |
|
| 17 | -Console::log(' '. Console::text("\$value = Console::ask('Please enter something > ', 'white', 'blue);", 'lightmagenta')); |
|
| 14 | +Console::log(' '.Console::text('Usage:', 'underlined', 'bold')); |
|
| 15 | +Console::log(' '.Console::text("\$value = Console::ask('Please enter something > ');", 'lightmagenta')); |
|
| 16 | +Console::log(' '.Console::text("// or", 'green')); |
|
| 17 | +Console::log(' '.Console::text("\$value = Console::ask('Please enter something > ', 'white', 'blue);", 'lightmagenta')); |
|
| 18 | 18 | Console::log(); |
| 19 | 19 | |
| 20 | 20 | // ----------------- |
| 21 | 21 | // sample start here |
| 22 | 22 | // ----------------- |
| 23 | 23 | $value = Console::ask('Please enter something > '); |
| 24 | -Console::log('=> the value you entered is [' . Console::text($value, 'lightyellow') . ']'); |
|
| 24 | +Console::log('=> the value you entered is ['.Console::text($value, 'lightyellow').']'); |
|
| 25 | 25 | |
| 26 | 26 | $value2 = Console::ask('Please enter something > ', 'magenta', 'underlined'); |
| 27 | -Console::log('=> the value you entered is [' . Console::text($value2, 'lightyellow') . ']'); |
|
| 27 | +Console::log('=> the value you entered is ['.Console::text($value2, 'lightyellow').']'); |
|
| 28 | 28 | |
| 29 | 29 | ?> |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
| 9 | 9 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
| 10 | 10 | Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
| 11 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 11 | + ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 12 | 12 | Console::log(); |
| 13 | 13 | Console::log(' '. Console::text('Warning:', 'underlined', 'bold')); |
| 14 | 14 | Console::log(' '. Console::text("User input are not hidden on windows platform (not supported)", 'red', 'yellow')); |
@@ -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::askPassword()", 'lightblue', 'underlined') . " to ask user to enter a value and return this value.", 'white'); |
|
| 5 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
| 6 | +Console::log(' Use '.Console::text("string ", 'blue').Console::text("Console::askPassword()", 'lightblue', 'underlined')." to ask user to enter a value and return this value.", 'white'); |
|
| 7 | 7 | Console::log(); |
| 8 | -Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
|
| 8 | +Console::log(' '.Console::text('Tips:', 'underlined', 'bold')); |
|
| 9 | 9 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
| 10 | -Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
|
| 11 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 10 | +Console::log(' with '.Console::text("Console::text()", 'lightblue', 'underlined'). |
|
| 11 | + ' and '.Console::text("Console::log()", 'lightblue', 'underlined').' methods.'); |
|
| 12 | 12 | Console::log(); |
| 13 | -Console::log(' '. Console::text('Warning:', 'underlined', 'bold')); |
|
| 14 | -Console::log(' '. Console::text("User input are not hidden on windows platform (not supported)", 'red', 'yellow')); |
|
| 13 | +Console::log(' '.Console::text('Warning:', 'underlined', 'bold')); |
|
| 14 | +Console::log(' '.Console::text("User input are not hidden on windows platform (not supported)", 'red', 'yellow')); |
|
| 15 | 15 | Console::log(); |
| 16 | -Console::log(' '. Console::text('Usage:', 'underlined', 'bold')); |
|
| 17 | -Console::log(' ' . Console::text("\$value = Console::askPassword('Please Enter something (We wont display it, for now...) > ');", 'lightmagenta')); |
|
| 18 | -Console::log(' ' . Console::text("Console::log();", 'lightmagenta')); |
|
| 19 | -Console::log(' ' . Console::text("Console::log('=> the value you entered is [' . Console::text(\$value, 'red') . ']');", 'lightmagenta')); |
|
| 16 | +Console::log(' '.Console::text('Usage:', 'underlined', 'bold')); |
|
| 17 | +Console::log(' '.Console::text("\$value = Console::askPassword('Please Enter something (We wont display it, for now...) > ');", 'lightmagenta')); |
|
| 18 | +Console::log(' '.Console::text("Console::log();", 'lightmagenta')); |
|
| 19 | +Console::log(' '.Console::text("Console::log('=> the value you entered is [' . Console::text(\$value, 'red') . ']');", 'lightmagenta')); |
|
| 20 | 20 | Console::log(); |
| 21 | -Console::log(' '. Console::text('Sample:', 'underlined', 'bold')); |
|
| 21 | +Console::log(' '.Console::text('Sample:', 'underlined', 'bold')); |
|
| 22 | 22 | |
| 23 | 23 | // ----------------- |
| 24 | 24 | // sample start here |
| 25 | 25 | // ----------------- |
| 26 | 26 | $value = Console::askPassword(' Please Enter something (We wont display it, for now... (except on windows) > '); |
| 27 | 27 | Console::log(); |
| 28 | -Console::log(' => the value you entered is [' . Console::text($value, 'red') . ']'); |
|
| 28 | +Console::log(' => the value you entered is ['.Console::text($value, 'red').']'); |
|
| 29 | 29 | |
| 30 | 30 | ?> |
| 31 | 31 | \ No newline at end of file |
@@ -9,7 +9,7 @@ |
||
| 9 | 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 | 11 | Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
| 12 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 12 | + ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
| 13 | 13 | Console::log(); |
| 14 | 14 | Console::log(' '. Console::text('Usage:', 'underlined', 'bold')); |
| 15 | 15 | Console::log(' ' . Console::text("\$value = Console::askInt('Please enter a number > ');", 'lightmagenta')); |
@@ -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')); |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | $i = 1; |
| 13 | 13 | foreach (Console::getStyles()['foregrounds'] as $color => $colorValue ){ |
| 14 | 14 | Console::log(' '.Console::tableRow([ |
| 15 | - ' ' . $i => 7, |
|
| 15 | + ' ' . $i => 7, |
|
| 16 | 16 | $color => 15, |
| 17 | - "\\033[" . $colorValue .'m' => 15, |
|
| 17 | + "\\033[" . $colorValue .'m' => 15, |
|
| 18 | 18 | Console::text(str_pad('I am a text color={' . $color .'}', 48), $color) => 50 |
| 19 | 19 | ])); |
| 20 | 20 | $i++; |
@@ -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 | // headers |
@@ -10,12 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | // loop into foregrounds |
| 12 | 12 | $i = 1; |
| 13 | -foreach (Console::getStyles()['foregrounds'] as $color => $colorValue ){ |
|
| 13 | +foreach (Console::getStyles()['foregrounds'] as $color => $colorValue) { |
|
| 14 | 14 | Console::log(' '.Console::tableRow([ |
| 15 | - ' ' . $i => 7, |
|
| 15 | + ' '.$i => 7, |
|
| 16 | 16 | $color => 15, |
| 17 | - "\\033[" . $colorValue .'m' => 15, |
|
| 18 | - Console::text(str_pad('I am a text color={' . $color .'}', 48), $color) => 50 |
|
| 17 | + "\\033[".$colorValue.'m' => 15, |
|
| 18 | + Console::text(str_pad('I am a text color={'.$color.'}', 48), $color) => 50 |
|
| 19 | 19 | ])); |
| 20 | 20 | $i++; |
| 21 | 21 | } |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | Console::$horizontalSeparator = '-'; // change the horizontal separator |
| 110 | 110 | Console::$tableCellPadding = ''; // no padding |
| 111 | 111 | Console::$verticalInnerSeparator = ' '; // blank separator |
| 112 | - Console::$verticalSeparator = ' '; // no top left/right separator except a margin.. |
|
| 112 | + Console::$verticalSeparator = ' '; // no top left/right separator except a margin.. |
|
| 113 | 113 | // Console::$verticalHeaderSeparator = ''; // no top left/right separator (not needed) |
| 114 | 114 | |
| 115 | 115 | // table start |
@@ -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 |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected static $defaultVerticalSign = '|'; |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * The default vertical sign. |
|
| 63 | - * |
|
| 64 | - * @access protected |
|
| 65 | - * @var string |
|
| 66 | - */ |
|
| 61 | + /** |
|
| 62 | + * The default vertical sign. |
|
| 63 | + * |
|
| 64 | + * @access protected |
|
| 65 | + * @var string |
|
| 66 | + */ |
|
| 67 | 67 | protected static $defaultVerticalInnerSign = '+'; |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static $verticalHeaderSeparator = '+'; |
| 108 | 108 | |
| 109 | - /** |
|
| 109 | + /** |
|
| 110 | 110 | * The vertical separator sign. |
| 111 | 111 | * |
| 112 | 112 | * @access public |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @return string |
| 259 | 259 | */ |
| 260 | - public static function tableRow() |
|
| 260 | + public static function tableRow() |
|
| 261 | 261 | { |
| 262 | 262 | // get and parse arguments: |
| 263 | 263 | // - extract first argument (columns list) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @access public |
| 81 | 81 | * @var string |
| 82 | 82 | */ |
| 83 | - public static $tableCellPadding = ' '; |
|
| 83 | + public static $tableCellPadding = ' '; |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * The horizontal separator sign. |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @access public |
| 97 | 97 | * @var string |
| 98 | 98 | */ |
| 99 | - public static $verticalSeparator = '|'; |
|
| 99 | + public static $verticalSeparator = '|'; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * The vertical header separator sign. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @access public |
| 105 | 105 | * @var string |
| 106 | 106 | */ |
| 107 | - public static $verticalHeaderSeparator = '+'; |
|
| 107 | + public static $verticalHeaderSeparator = '+'; |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * The vertical separator sign. |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @access public |
| 113 | 113 | * @var string |
| 114 | 114 | */ |
| 115 | - public static $verticalInnerSeparator = '+'; |
|
| 115 | + public static $verticalInnerSeparator = '+'; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Resets the default options |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | $columnsPads = !empty($args) ? $args[0] : []; |
| 149 | 149 | array_shift($args); |
| 150 | 150 | |
| 151 | - $str = self::$verticalSeparator ; |
|
| 152 | - $cellPaddingLenght = mb_strlen(self::$tableCellPadding) *2; |
|
| 153 | - foreach ($columnsPads as $key => $pad){ |
|
| 154 | - $str .= str_repeat(self::$horizontalSeparator , $pad + $cellPaddingLenght) .self::$verticalInnerSeparator; |
|
| 151 | + $str = self::$verticalSeparator; |
|
| 152 | + $cellPaddingLenght = mb_strlen(self::$tableCellPadding)*2; |
|
| 153 | + foreach ($columnsPads as $key => $pad) { |
|
| 154 | + $str .= str_repeat(self::$horizontalSeparator, $pad+$cellPaddingLenght).self::$verticalInnerSeparator; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, mb_strlen($str) -1). self::$verticalSeparator, $args); |
|
| 157 | + return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, mb_strlen($str)-1).self::$verticalSeparator, $args); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | $columnsPads = !empty($args) ? $args[0] : []; |
| 175 | 175 | array_shift($args); |
| 176 | 176 | |
| 177 | - $str = self::$verticalHeaderSeparator ; |
|
| 178 | - $cellPaddingLenght = mb_strlen(self::$tableCellPadding) *2; |
|
| 179 | - foreach ($columnsPads as $key => $pad){ |
|
| 180 | - $str .= str_repeat(self::$horizontalSeparator , $pad + $cellPaddingLenght) .self::$verticalInnerSeparator ; |
|
| 177 | + $str = self::$verticalHeaderSeparator; |
|
| 178 | + $cellPaddingLenght = mb_strlen(self::$tableCellPadding)*2; |
|
| 179 | + foreach ($columnsPads as $key => $pad) { |
|
| 180 | + $str .= str_repeat(self::$horizontalSeparator, $pad+$cellPaddingLenght).self::$verticalInnerSeparator; |
|
| 181 | 181 | } |
| 182 | - return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, mb_strlen($str) -1). self::$verticalHeaderSeparator, $args); |
|
| 182 | + return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, mb_strlen($str)-1).self::$verticalHeaderSeparator, $args); |
|
| 183 | 183 | |
| 184 | 184 | } |
| 185 | 185 | |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | $columnsPads = !empty($args) ? $args[0] : []; |
| 204 | 204 | array_shift($args); |
| 205 | 205 | |
| 206 | - $str = self::$verticalSeparator ; |
|
| 207 | - foreach ($columnsPads as $pad){ |
|
| 206 | + $str = self::$verticalSeparator; |
|
| 207 | + foreach ($columnsPads as $pad) { |
|
| 208 | 208 | $str .= self::$tableCellPadding. |
| 209 | 209 | str_pad(' ', $pad). |
| 210 | 210 | self::$tableCellPadding. |
| 211 | - self::$verticalSeparator ; |
|
| 211 | + self::$verticalSeparator; |
|
| 212 | 212 | } |
| 213 | 213 | return self::getCliString($str, $args); |
| 214 | 214 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $str = self::$verticalSeparator; |
| 272 | 272 | |
| 273 | 273 | // add columns |
| 274 | - foreach ($columns as $column => $pad){ |
|
| 274 | + foreach ($columns as $column => $pad) { |
|
| 275 | 275 | $str .= self::$tableCellPadding. |
| 276 | 276 | self::pad($column, $pad). |
| 277 | 277 | self::$tableCellPadding. |
@@ -279,6 +279,6 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // format full row |
| 282 | - return self::getCliString($str, $args) ; |
|
| 282 | + return self::getCliString($str, $args); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public static function inArguments(array $arguments, string $shortArg, string $longArg) |
| 49 | 49 | { |
| 50 | - return array_key_exists($shortArg, $arguments) || array_key_exists($longArg, $arguments); |
|
| 50 | + return array_key_exists($shortArg, $arguments) || array_key_exists($longArg, $arguments); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public static function getArgumentValue(array $arguments, string $shortArg, string $longArg):? string |
| 67 | 67 | { |
| 68 | - return array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : |
|
| 68 | + return array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : |
|
| 69 | 69 | (array_key_exists($longArg, $arguments) ? $arguments[$longArg] : null); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @version 1.6.2 |
| 15 | 15 | * @copyright 2017-2024 Kr157uff |
| 16 | 16 | */ |
| 17 | -declare(ticks = 1); // Allow posix signal handling |
|
| 17 | +declare(ticks=1); // Allow posix signal handling |
|
| 18 | 18 | |
| 19 | 19 | namespace Kristuff\Mishell; |
| 20 | 20 | |
@@ -62,10 +62,9 @@ discard block |
||
| 62 | 62 | * @return string|null |
| 63 | 63 | * |
| 64 | 64 | */ |
| 65 | - public static function getArgumentValue(array $arguments, string $shortArg, string $longArg):? string |
|
| 65 | + public static function getArgumentValue(array $arguments, string $shortArg, string $longArg): ? string |
|
| 66 | 66 | { |
| 67 | - return array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : |
|
| 68 | - (array_key_exists($longArg, $arguments) ? $arguments[$longArg] : null); |
|
| 67 | + return array_key_exists($shortArg, $arguments) ? $arguments[$shortArg] : (array_key_exists($longArg, $arguments) ? $arguments[$longArg] : null); |
|
| 69 | 68 | } |
| 70 | 69 | |
| 71 | 70 | } |
| 72 | 71 | \ No newline at end of file |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInite5eca23334d547f58d55dd3321eace6e::getLoader(); |