@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public static function getColumns() |
| 55 | 55 | { |
| 56 | - if (!self::isWin() ){ |
|
| 56 | + if (!self::isWin()) { |
|
| 57 | 57 | return (int) shell_exec('tput cols'); |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public static function getLines() |
| 70 | 70 | { |
| 71 | - if (!self::isWin() ){ |
|
| 71 | + if (!self::isWin()) { |
|
| 72 | 72 | return (int) shell_exec('tput lines'); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public static function newWindow() |
| 85 | 85 | { |
| 86 | - if (!self::isWin() ){ |
|
| 86 | + if (!self::isWin()) { |
|
| 87 | 87 | system('tput smcup'); |
| 88 | 88 | self::clear(); |
| 89 | 89 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public static function restoreWindow() |
| 101 | 101 | { |
| 102 | - if (!self::isWin() ){ |
|
| 102 | + if (!self::isWin()) { |
|
| 103 | 103 | system('tput rmcup'); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public static function hideInput() |
| 116 | 116 | { |
| 117 | - if (!self::isWin() ){ |
|
| 117 | + if (!self::isWin()) { |
|
| 118 | 118 | system('stty -echo'); |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public static function restoreInput() |
| 131 | 131 | { |
| 132 | - if (!self::isWin()){ |
|
| 132 | + if (!self::isWin()) { |
|
| 133 | 133 | system('stty echo'); |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -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 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public static $verticalSeparator = '|'; |
| 100 | 100 | |
| 101 | - /** |
|
| 101 | + /** |
|
| 102 | 102 | * The vertical separator sign. |
| 103 | 103 | * |
| 104 | 104 | * @access public |
@@ -148,17 +148,17 @@ discard block |
||
| 148 | 148 | return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, strlen($str) -1). self::$verticalSeparator, $args); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Gets a formated table row separator |
|
| 153 | - * |
|
| 154 | - * @access public |
|
| 155 | - * @static method |
|
| 156 | - * @param string [$color] The text color for the wall row |
|
| 157 | - * @param string [$bgcolor] The back color for the wall row |
|
| 158 | - * @param string [$option]+... The text styles for the wall row |
|
| 159 | - * |
|
| 160 | - * @return string |
|
| 161 | - */ |
|
| 151 | + /** |
|
| 152 | + * Gets a formated table row separator |
|
| 153 | + * |
|
| 154 | + * @access public |
|
| 155 | + * @static method |
|
| 156 | + * @param string [$color] The text color for the wall row |
|
| 157 | + * @param string [$bgcolor] The back color for the wall row |
|
| 158 | + * @param string [$option]+... The text styles for the wall row |
|
| 159 | + * |
|
| 160 | + * @return string |
|
| 161 | + */ |
|
| 162 | 162 | public static function tableSeparator() |
| 163 | 163 | { |
| 164 | 164 | $args = func_get_args(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return string |
| 249 | 249 | */ |
| 250 | - public static function tableRow() |
|
| 250 | + public static function tableRow() |
|
| 251 | 251 | { |
| 252 | 252 | // get and parse arguments: |
| 253 | 253 | // - 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 separator sign. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @access public |
| 105 | 105 | * @var string |
| 106 | 106 | */ |
| 107 | - public static $verticalInnerSeparator = '+'; |
|
| 107 | + public static $verticalInnerSeparator = '+'; |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Resets the default options |
@@ -139,13 +139,13 @@ discard block |
||
| 139 | 139 | $columnsPads = !empty($args) ? $args[0] : []; |
| 140 | 140 | array_shift($args); |
| 141 | 141 | |
| 142 | - $str = self::$verticalSeparator ; |
|
| 143 | - $cellPaddingLenght = strlen(self::$tableCellPadding) *2; |
|
| 144 | - foreach ($columnsPads as $key => $pad){ |
|
| 145 | - $str .= str_repeat(self::$horizontalSeparator , $pad + $cellPaddingLenght) .self::$verticalInnerSeparator ; |
|
| 142 | + $str = self::$verticalSeparator; |
|
| 143 | + $cellPaddingLenght = strlen(self::$tableCellPadding)*2; |
|
| 144 | + foreach ($columnsPads as $key => $pad) { |
|
| 145 | + $str .= str_repeat(self::$horizontalSeparator, $pad+$cellPaddingLenght).self::$verticalInnerSeparator; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, strlen($str) -1). self::$verticalSeparator, $args); |
|
| 148 | + return self::getCliString(self::$verticalInnerSeparator === '' ? $str : substr($str, 0, strlen($str)-1).self::$verticalSeparator, $args); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | $columnsPads = !empty($args) ? $args[0] : []; |
| 166 | 166 | array_shift($args); |
| 167 | 167 | |
| 168 | - $str = self::$verticalSeparator ; |
|
| 169 | - $cellPaddingLenght = strlen(self::$tableCellPadding) *2; |
|
| 170 | - foreach ($columnsPads as $key => $pad){ |
|
| 171 | - $str .= str_repeat(self::$horizontalSeparator , $pad + $cellPaddingLenght) .self::$horizontalSeparator; |
|
| 168 | + $str = self::$verticalSeparator; |
|
| 169 | + $cellPaddingLenght = strlen(self::$tableCellPadding)*2; |
|
| 170 | + foreach ($columnsPads as $key => $pad) { |
|
| 171 | + $str .= str_repeat(self::$horizontalSeparator, $pad+$cellPaddingLenght).self::$horizontalSeparator; |
|
| 172 | 172 | } |
| 173 | - return self::getCliString(substr($str, 0, strlen($str) -1). self::$verticalSeparator, $args); |
|
| 173 | + return self::getCliString(substr($str, 0, strlen($str)-1).self::$verticalSeparator, $args); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | $columnsPads = !empty($args) ? $args[0] : []; |
| 194 | 194 | array_shift($args); |
| 195 | 195 | |
| 196 | - $str = self::$verticalSeparator ; |
|
| 197 | - foreach ($columnsPads as $pad){ |
|
| 196 | + $str = self::$verticalSeparator; |
|
| 197 | + foreach ($columnsPads as $pad) { |
|
| 198 | 198 | $str .= self::$tableCellPadding. |
| 199 | 199 | str_pad(' ', $pad). |
| 200 | 200 | self::$tableCellPadding. |
| 201 | - self::$verticalSeparator ; |
|
| 201 | + self::$verticalSeparator; |
|
| 202 | 202 | } |
| 203 | 203 | return self::getCliString($str, $args); |
| 204 | 204 | } |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $str = self::$verticalSeparator; |
| 262 | 262 | |
| 263 | 263 | // add columns |
| 264 | - foreach ($columns as $column => $pad){ |
|
| 264 | + foreach ($columns as $column => $pad) { |
|
| 265 | 265 | $str .= self::$tableCellPadding. |
| 266 | 266 | self::pad($column, $pad). |
| 267 | 267 | self::$tableCellPadding. |
@@ -269,6 +269,6 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // format full row |
| 272 | - return self::getCliString($str, $args) ; |
|
| 272 | + return self::getCliString($str, $args); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @var array |
| 30 | 30 | */ |
| 31 | 31 | protected static $foregroundColors = array( |
| 32 | - 'normal' => '39', // your default color |
|
| 32 | + 'normal' => '39', // your default color |
|
| 33 | 33 | 'black' => '30', |
| 34 | 34 | 'gray' => '1;30', |
| 35 | 35 | 'lightgray' => '37', |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | * @var array |
| 75 | 75 | */ |
| 76 | 76 | protected static $options = array( |
| 77 | - 'none' => '0', // reset all styles |
|
| 78 | - 'bold' => '1', // |
|
| 77 | + 'none' => '0', // reset all styles |
|
| 78 | + 'bold' => '1', // |
|
| 79 | 79 | 'underline' => '4', |
| 80 | 80 | 'blink' => '5', |
| 81 | - 'reverse' => '7', // reverse foreground/background color |
|
| 81 | + 'reverse' => '7', // reverse foreground/background color |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -117,27 +117,27 @@ discard block |
||
| 117 | 117 | array_shift($args); |
| 118 | 118 | |
| 119 | 119 | // |
| 120 | - switch($command){ |
|
| 120 | + switch ($command) { |
|
| 121 | 121 | |
| 122 | 122 | // **************************************** |
| 123 | 123 | // Get methods (return string) |
| 124 | 124 | // **************************************** |
| 125 | 125 | |
| 126 | 126 | case'text': |
| 127 | - return self::getCliString($str, $args); // get formated text |
|
| 127 | + return self::getCliString($str, $args); // get formated text |
|
| 128 | 128 | |
| 129 | 129 | // **************************************** |
| 130 | 130 | // Write methods (echo and return null) |
| 131 | 131 | // **************************************** |
| 132 | 132 | |
| 133 | 133 | case'write': |
| 134 | - echo (self::getCliString($str, $args)); // write text |
|
| 134 | + echo (self::getCliString($str, $args)); // write text |
|
| 135 | 135 | break; |
| 136 | 136 | case'log': |
| 137 | - echo (self::getCliString($str, $args) . self::$EOF ); // write text + newline |
|
| 137 | + echo (self::getCliString($str, $args).self::$EOF); // write text + newline |
|
| 138 | 138 | break; |
| 139 | 139 | case'relog': |
| 140 | - echo (self::getCliString($str ."\r", $args)); // overwrite current line |
|
| 140 | + echo (self::getCliString($str."\r", $args)); // overwrite current line |
|
| 141 | 141 | break; |
| 142 | 142 | |
| 143 | 143 | // **************************************** |
@@ -145,19 +145,19 @@ discard block |
||
| 145 | 145 | // **************************************** |
| 146 | 146 | |
| 147 | 147 | case'ask': |
| 148 | - echo (self::getCliString($str, $args)); // write question |
|
| 149 | - return trim(fgets(STDIN)); // reads and return one line from STDIN |
|
| 148 | + echo (self::getCliString($str, $args)); // write question |
|
| 149 | + return trim(fgets(STDIN)); // reads and return one line from STDIN |
|
| 150 | 150 | |
| 151 | 151 | case'askPassword': |
| 152 | - self::hideInput(); // hide |
|
| 153 | - echo (self::getCliString($str, $args)); // write question |
|
| 154 | - $line= trim(fgets(STDIN)); // reads one line from STDIN |
|
| 155 | - self::restoreInput(); // restore |
|
| 156 | - return $line; // return line |
|
| 152 | + self::hideInput(); // hide |
|
| 153 | + echo (self::getCliString($str, $args)); // write question |
|
| 154 | + $line = trim(fgets(STDIN)); // reads one line from STDIN |
|
| 155 | + self::restoreInput(); // restore |
|
| 156 | + return $line; // return line |
|
| 157 | 157 | |
| 158 | 158 | case 'askInt': |
| 159 | - echo (self::getCliString($str, $args)); // write question |
|
| 160 | - fscanf(STDIN, "%d\n", $number); // reads number from STDIN |
|
| 159 | + echo (self::getCliString($str, $args)); // write question |
|
| 160 | + fscanf(STDIN, "%d\n", $number); // reads number from STDIN |
|
| 161 | 161 | return (is_int($number) ? $number : false); // return int value or false |
| 162 | 162 | } |
| 163 | 163 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected static function getCliString($str, array $arguments = []) |
| 179 | 179 | { |
| 180 | - if (empty($arguments)){ |
|
| 180 | + if (empty($arguments)) { |
|
| 181 | 181 | return $str; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -190,24 +190,24 @@ discard block |
||
| 190 | 190 | foreach ($arguments as $argument) { |
| 191 | 191 | |
| 192 | 192 | // it's a color? |
| 193 | - if(!$hasColor && isset(self::$foregroundColors[$argument])){ |
|
| 193 | + if (!$hasColor && isset(self::$foregroundColors[$argument])) { |
|
| 194 | 194 | $cliArgs[] = self::$foregroundColors[$argument]; |
| 195 | 195 | $hasColor = true; |
| 196 | 196 | |
| 197 | 197 | // it's a backcolor? |
| 198 | - } elseif ($hasColor && !$hasBackColor && isset(self::$backgroundColors[$argument])){ |
|
| 198 | + } elseif ($hasColor && !$hasBackColor && isset(self::$backgroundColors[$argument])) { |
|
| 199 | 199 | $cliArgs[] = self::$backgroundColors[$argument]; |
| 200 | 200 | $hasBackColor = true; |
| 201 | 201 | |
| 202 | 202 | // or it's an option? |
| 203 | - } elseif (isset(self::$options[$argument])){ |
|
| 203 | + } elseif (isset(self::$options[$argument])) { |
|
| 204 | 204 | $cliArgs[] = self::$options[$argument]; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Add string and end coloring |
| 209 | - $coloredString .= "\033[" . implode(';',$cliArgs) .'m'; |
|
| 210 | - $coloredString .= $str . "\033[0m"; |
|
| 209 | + $coloredString .= "\033[".implode(';', $cliArgs).'m'; |
|
| 210 | + $coloredString .= $str."\033[0m"; |
|
| 211 | 211 | return $coloredString; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | */ |
| 292 | 292 | public static function askPassword() |
| 293 | 293 | { |
| 294 | - return self::cmd('askPassword',func_get_args()); |
|
| 294 | + return self::cmd('askPassword', func_get_args()); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public static function log() |
| 310 | 310 | { |
| 311 | - self::cmd('log',func_get_args()); |
|
| 311 | + self::cmd('log', func_get_args()); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public static function relog() |
| 327 | 327 | { |
| 328 | - self::cmd('relog',func_get_args()); |
|
| 328 | + self::cmd('relog', func_get_args()); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -342,20 +342,20 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function pad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT) |
| 344 | 344 | { |
| 345 | - $diff = $padLength - strlen(preg_replace('#\\033\[[[0-9;*]{1,}m#', '', $input)); |
|
| 345 | + $diff = $padLength-strlen(preg_replace('#\\033\[[[0-9;*]{1,}m#', '', $input)); |
|
| 346 | 346 | |
| 347 | - if ($diff > 0){ |
|
| 348 | - switch ($padType){ |
|
| 347 | + if ($diff > 0) { |
|
| 348 | + switch ($padType) { |
|
| 349 | 349 | |
| 350 | 350 | case STR_PAD_RIGHT: |
| 351 | - return $input . str_repeat($padString, $diff); |
|
| 351 | + return $input.str_repeat($padString, $diff); |
|
| 352 | 352 | |
| 353 | 353 | case STR_PAD_LEFT: |
| 354 | - return str_repeat($padString, $diff ) . $input; |
|
| 354 | + return str_repeat($padString, $diff).$input; |
|
| 355 | 355 | |
| 356 | 356 | case STR_PAD_BOTH: |
| 357 | 357 | $padLeft = round(($diff)/2); |
| 358 | - return str_repeat($padString, $padLeft) . $input . str_repeat($padString, $diff - $padLeft); |
|
| 358 | + return str_repeat($padString, $padLeft).$input.str_repeat($padString, $diff-$padLeft); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | return $input; |
@@ -1,11 +1,11 @@ discard block |
||
| 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 | 6 | |
| 7 | 7 | Console::log('Overview:', 'underline', 'bold'); |
| 8 | -Console::log(" - Use " . Console::text("Console::askInt(\$str [\$styles])", 'blue', 'white') . " to ask user to enter a number in the console."); |
|
| 8 | +Console::log(" - Use ".Console::text("Console::askInt(\$str [\$styles])", 'blue', 'white')." to ask user to enter a number in the console."); |
|
| 9 | 9 | Console::log(''); |
| 10 | 10 | Console::log('Tips:', 'underline', 'bold'); |
| 11 | 11 | Console::log(" - The method returns Int value or False if the entered value is not a valid int number.", 'lightmagenta'); |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | Console::log(" and Console::log() methods..", 'lightmagenta'); |
| 14 | 14 | Console::log(''); |
| 15 | 15 | Console::log('Usage:', 'underline', 'bold'); |
| 16 | -Console::log(' ' . Console::text(Console::pad("\$value = Console::askInt('Please enter a number > ');", 80), 'blue', 'white')); |
|
| 17 | -Console::log(' ' . Console::text(Console::pad("if (\$value !== false) {", 80), 'blue', 'white')); |
|
| 18 | -Console::log(' ' . Console::text(Console::pad(" [...]", 80), 'blue', 'white')); |
|
| 16 | +Console::log(' '.Console::text(Console::pad("\$value = Console::askInt('Please enter a number > ');", 80), 'blue', 'white')); |
|
| 17 | +Console::log(' '.Console::text(Console::pad("if (\$value !== false) {", 80), 'blue', 'white')); |
|
| 18 | +Console::log(' '.Console::text(Console::pad(" [...]", 80), 'blue', 'white')); |
|
| 19 | 19 | Console::log(''); |
| 20 | 20 | Console::log('Sample:', 'underline', 'bold'); |
| 21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $value = Console::askInt('Please enter a number > '); |
| 25 | 25 | |
| 26 | - if ($value !== false){ |
|
| 27 | - Console::log('=> The value you entered is [' . Console::text($value, 'yellow') . ']'); |
|
| 26 | + if ($value !== false) { |
|
| 27 | + Console::log('=> The value you entered is ['.Console::text($value, 'yellow').']'); |
|
| 28 | 28 | |
| 29 | 29 | } else { |
| 30 | 30 | Console::log(Console::text('Error:', 'red')); |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $i = 0; |
| 126 | 126 | foreach (getIndex() as $key => $value){ |
| 127 | 127 | |
| 128 | - if (file_exists( __DIR__ . '/'. $value[2])) { |
|
| 128 | + if (file_exists( __DIR__ . '/'. $value[2])) { |
|
| 129 | 129 | Console::log(' '. |
| 130 | 130 | Console::tableRow([ |
| 131 | 131 | $key => 10, |
@@ -179,23 +179,23 @@ discard block |
||
| 179 | 179 | writeSampleHeader($selectedIndex, $title); |
| 180 | 180 | |
| 181 | 181 | Console::log($base . Console::text('Start running [', 'white') . |
| 182 | - Console::text( $title, 'lightcyan') . |
|
| 183 | - Console::text('] in file [', 'white') . |
|
| 184 | - Console::text( $fileName, 'lightcyan') . |
|
| 185 | - Console::text(']', 'white')); |
|
| 182 | + Console::text( $title, 'lightcyan') . |
|
| 183 | + Console::text('] in file [', 'white') . |
|
| 184 | + Console::text( $fileName, 'lightcyan') . |
|
| 185 | + Console::text(']', 'white')); |
|
| 186 | 186 | |
| 187 | 187 | if (file_exists($filePath)){ |
| 188 | 188 | Console::log(); |
| 189 | 189 | include $filePath; |
| 190 | 190 | Console::log(); |
| 191 | 191 | Console::log($base . Console::text('End running [', 'white') . |
| 192 | - Console::text( $title, 'lightcyan') . |
|
| 193 | - Console::text(']', 'white')); |
|
| 192 | + Console::text( $title, 'lightcyan') . |
|
| 193 | + Console::text(']', 'white')); |
|
| 194 | 194 | $response = Console::ask($base . Console::text('Do you want to see the code that has been executed? (type y/Y to see the code) > ', 'white')); |
| 195 | - if (strtoupper($response) === 'Y') { |
|
| 195 | + if (strtoupper($response) === 'Y') { |
|
| 196 | 196 | Console::log($base . Console::text('The code in file [', 'white') . |
| 197 | - Console::text( $fileName, 'lightcyan') . |
|
| 198 | - Console::text('] is:', 'white')); |
|
| 197 | + Console::text( $fileName, 'lightcyan') . |
|
| 198 | + Console::text('] is:', 'white')); |
|
| 199 | 199 | Console::log(); |
| 200 | 200 | |
| 201 | 201 | $lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | Console::log(); |
| 213 | 213 | } |
| 214 | - } else { |
|
| 214 | + } else { |
|
| 215 | 215 | Console::log($base . Console::text('Error' , 'red')); |
| 216 | 216 | Console::log($base . Console::text(' => File missing [' . $fileName . ']' , 'red')); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | } else { |
| 220 | 220 | Console::log($base . Console::text('Error:', 'red')); |
@@ -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 | Console::clear(); |
@@ -18,26 +18,26 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | Console::log(); |
| 20 | 20 | Console::log(); |
| 21 | - Console::log(' '. Console::text(" _ ", 'black', 'white') . Console::text(" ____ _ _ _ ", 'magenta', 'white')); |
|
| 22 | - Console::log(' '. Console::text(" _ __ ___ (_) ", 'black', 'white') . Console::text(" / ___|| |__ ___| | | ", 'magenta', 'white')); |
|
| 23 | - Console::log(' '. Console::text(" | '_ ` _ \| | ", 'black', 'white') . Console::text(" \___ \| '_ \ / _ \ | | ", 'magenta', 'white')); |
|
| 24 | - Console::log(' '. Console::text(" | | | | | | | ", 'black', 'white') . Console::text(" ___) | | | | __/ | | ", 'magenta', 'white')); |
|
| 25 | - Console::log(' '. Console::text(" |_| |_| |_|_| ", 'black', 'white') . Console::text(" |____/|_| |_|\___|_|_| ", 'magenta', 'white')); |
|
| 26 | - Console::log(' '. Console::text(" ", 'black', 'white') . Console::text(" ", 'magenta', 'white')); |
|
| 27 | - Console::log(' '. Console::text(" ", 'black', 'white') . Console::text(" Version 1.0 ", 'black', 'white')); |
|
| 28 | - Console::log(' '. Console::text(" ", 'black', 'white') . Console::text(" © 2020 Kristuff ", 'black', 'white')); |
|
| 29 | - Console::log(' '. Console::text(" ", 'black', 'white') . Console::text(" ", 'magenta', 'white')); |
|
| 21 | + Console::log(' '.Console::text(" _ ", 'black', 'white').Console::text(" ____ _ _ _ ", 'magenta', 'white')); |
|
| 22 | + Console::log(' '.Console::text(" _ __ ___ (_) ", 'black', 'white').Console::text(" / ___|| |__ ___| | | ", 'magenta', 'white')); |
|
| 23 | + Console::log(' '.Console::text(" | '_ ` _ \| | ", 'black', 'white').Console::text(" \___ \| '_ \ / _ \ | | ", 'magenta', 'white')); |
|
| 24 | + Console::log(' '.Console::text(" | | | | | | | ", 'black', 'white').Console::text(" ___) | | | | __/ | | ", 'magenta', 'white')); |
|
| 25 | + Console::log(' '.Console::text(" |_| |_| |_|_| ", 'black', 'white').Console::text(" |____/|_| |_|\___|_|_| ", 'magenta', 'white')); |
|
| 26 | + Console::log(' '.Console::text(" ", 'black', 'white').Console::text(" ", 'magenta', 'white')); |
|
| 27 | + Console::log(' '.Console::text(" ", 'black', 'white').Console::text(" Version 1.0 ", 'black', 'white')); |
|
| 28 | + Console::log(' '.Console::text(" ", 'black', 'white').Console::text(" © 2020 Kristuff ", 'black', 'white')); |
|
| 29 | + Console::log(' '.Console::text(" ", 'black', 'white').Console::text(" ", 'magenta', 'white')); |
|
| 30 | 30 | Console::log(); |
| 31 | 31 | Console::log(); |
| 32 | 32 | |
| 33 | 33 | $pad = ' '; |
| 34 | 34 | |
| 35 | 35 | // fake progress message |
| 36 | - for ($i=0 ; $i<=100 ; $i++) { |
|
| 36 | + for ($i = 0; $i <= 100; $i++) { |
|
| 37 | 37 | |
| 38 | 38 | // Overwrite progress message. |
| 39 | 39 | Console::relog($pad.Console::text('Loading... [', 'white'). |
| 40 | - Console::text($i .'%', 'green'). |
|
| 40 | + Console::text($i.'%', 'green'). |
|
| 41 | 41 | Console::text('] completed', 'white')); |
| 42 | 42 | |
| 43 | 43 | // wait for a while, so we see the animation |
@@ -55,25 +55,25 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | |
| 58 | - $index[1] = ['Styles', 'How to get available basic styles', 'demo.styles.php']; |
|
| 59 | - $index[2] = ['Colors', 'How to get available foreground colors', 'demo.colors.php']; |
|
| 60 | - $index[3] = ['Backgrounds', 'How to get available background colors', 'demo.bgcolors.php']; |
|
| 58 | + $index[1] = ['Styles', 'How to get available basic styles', 'demo.styles.php']; |
|
| 59 | + $index[2] = ['Colors', 'How to get available foreground colors', 'demo.colors.php']; |
|
| 60 | + $index[3] = ['Backgrounds', 'How to get available background colors', 'demo.bgcolors.php']; |
|
| 61 | 61 | |
| 62 | - $index[11] = ['Ask', 'How to ask? (get user input)', 'demo.ask.php']; |
|
| 63 | - $index[12] = ['Ask Number', 'How to ask and expect a number?', 'demo.askint.php']; |
|
| 64 | - $index[13] = ['Ask Password', 'How to ask a password? (do not print user input)', 'demo.askpassword.php']; |
|
| 62 | + $index[11] = ['Ask', 'How to ask? (get user input)', 'demo.ask.php']; |
|
| 63 | + $index[12] = ['Ask Number', 'How to ask and expect a number?', 'demo.askint.php']; |
|
| 64 | + $index[13] = ['Ask Password', 'How to ask a password? (do not print user input)', 'demo.askpassword.php']; |
|
| 65 | 65 | |
| 66 | - $index[14] = ['Table', 'How to print a table?', 'demo.table.php']; |
|
| 67 | - $index[15] = ['Bell', 'How to run the bell?', 'demo.bell.php']; |
|
| 68 | - $index[16] = ['Progress', 'How to output progress message?', 'demo.progress.php']; |
|
| 69 | - $index[17] = ['New window', 'How to open new/restore window?', 'demo.window.php']; |
|
| 66 | + $index[14] = ['Table', 'How to print a table?', 'demo.table.php']; |
|
| 67 | + $index[15] = ['Bell', 'How to run the bell?', 'demo.bell.php']; |
|
| 68 | + $index[16] = ['Progress', 'How to output progress message?', 'demo.progress.php']; |
|
| 69 | + $index[17] = ['New window', 'How to open new/restore window?', 'demo.window.php']; |
|
| 70 | 70 | |
| 71 | 71 | // $index[4] = ['Text', 'Console::text() overview', 'demo.log.php']; |
| 72 | 72 | // $index[5] = ['Log', 'Console::log() overview', 'demo.log.php']; |
| 73 | 73 | // $index[6] = ['ReLog', 'Console::relog() overview', 'demo.relog.php']; |
| 74 | - $index[7] = ['Pad', 'Console::pad() overview', 'demo.pad.php']; |
|
| 75 | - $index[8] = ['Size', 'How to get the number of columns and lines in terminal', 'demo.size.php']; |
|
| 76 | - $index[9] = ['BlueScreen', 'Really nice full screen centered message sample', 'demo.bluescreen.php']; |
|
| 74 | + $index[7] = ['Pad', 'Console::pad() overview', 'demo.pad.php']; |
|
| 75 | + $index[8] = ['Size', 'How to get the number of columns and lines in terminal', 'demo.size.php']; |
|
| 76 | + $index[9] = ['BlueScreen', 'Really nice full screen centered message sample', 'demo.bluescreen.php']; |
|
| 77 | 77 | |
| 78 | 78 | return $index; |
| 79 | 79 | } |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | function writeSampleHeader($index, $title) |
| 93 | 93 | { |
| 94 | - Console::log(' ' . Console::text(Console::pad('', 20, ' ', STR_PAD_BOTH), 'white', 'bold', 'underline')); |
|
| 95 | - Console::log(' ' . Console::text(Console::pad('', 20, ' ', STR_PAD_BOTH), 'white', 'yellow', 'bold')); |
|
| 96 | - Console::log(' ' . Console::text(Console::pad($index .' - ' . $title, 20, ' ', STR_PAD_BOTH), 'white', 'yellow', 'bold')); |
|
| 97 | - Console::log(' ' . Console::text(Console::pad('', 20, ' ', STR_PAD_BOTH), 'white', 'yellow', 'bold', 'underline')); |
|
| 94 | + Console::log(' '.Console::text(Console::pad('', 20, ' ', STR_PAD_BOTH), 'white', 'bold', 'underline')); |
|
| 95 | + Console::log(' '.Console::text(Console::pad('', 20, ' ', STR_PAD_BOTH), 'white', 'yellow', 'bold')); |
|
| 96 | + Console::log(' '.Console::text(Console::pad($index.' - '.$title, 20, ' ', STR_PAD_BOTH), 'white', 'yellow', 'bold')); |
|
| 97 | + Console::log(' '.Console::text(Console::pad('', 20, ' ', STR_PAD_BOTH), 'white', 'yellow', 'bold', 'underline')); |
|
| 98 | 98 | Console::log(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | function writeIndex() |
| 102 | 102 | { |
| 103 | - Console::log(' '. Console::text('Index:', 'underline', 'bold')); |
|
| 103 | + Console::log(' '.Console::text('Index:', 'underline', 'bold')); |
|
| 104 | 104 | $rowHeaders = ['Index' => 10, 'Item' => 25, 'Description' => 70]; |
| 105 | 105 | |
| 106 | 106 | // customize table separator |
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | Console::log(' '.Console::tableRowEmpty($rowHeaders, 'white', 'cyan')); |
| 126 | 126 | |
| 127 | 127 | $i = 0; |
| 128 | - foreach (getIndex() as $key => $value){ |
|
| 128 | + foreach (getIndex() as $key => $value) { |
|
| 129 | 129 | |
| 130 | - if (file_exists( __DIR__ . '/'. $value[2])) { |
|
| 130 | + if (file_exists(__DIR__.'/'.$value[2])) { |
|
| 131 | 131 | Console::log(' '. |
| 132 | 132 | Console::tableRow([ |
| 133 | 133 | $key => 10, |
| 134 | 134 | $value[0] => 25, |
| 135 | 135 | $value[1] => 70 |
| 136 | 136 | ], |
| 137 | - ($i % 2 == 1) ? 'white' : 'white', |
|
| 138 | - ($i % 2 == 1) ? 'cyan' : 'cyan', |
|
| 139 | - ($i % 2 == 1) ? '' : 'bold' |
|
| 137 | + ($i%2 == 1) ? 'white' : 'white', |
|
| 138 | + ($i%2 == 1) ? 'cyan' : 'cyan', |
|
| 139 | + ($i%2 == 1) ? '' : 'bold' |
|
| 140 | 140 | ) |
| 141 | 141 | ); |
| 142 | 142 | $i++; |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | // -------------------- |
| 152 | 152 | |
| 153 | 153 | Console::log(''); |
| 154 | - Console::log(' ' .Console::text('Tips:', 'underline', 'bold')); |
|
| 155 | - Console::log(' '. Console::text('- At any time you can stop this program using [', 'green') .Console::text('Ctrl+C', 'black','white') .Console::text(']', 'green')); |
|
| 154 | + Console::log(' '.Console::text('Tips:', 'underline', 'bold')); |
|
| 155 | + Console::log(' '.Console::text('- At any time you can stop this program using [', 'green').Console::text('Ctrl+C', 'black', 'white').Console::text(']', 'green')); |
|
| 156 | 156 | Console::log(''); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | function askIndex() |
| 160 | 160 | { |
| 161 | - $base = Console::text('~miShell^^' , 'yellow'); |
|
| 162 | - $base .= Console::text(' $ ' , 'gray'); |
|
| 163 | - $selectedIndex = Console::askInt($base . Console::text('Enter desired index then press [Enter] to run sample > ', 'white')); |
|
| 161 | + $base = Console::text('~miShell^^', 'yellow'); |
|
| 162 | + $base .= Console::text(' $ ', 'gray'); |
|
| 163 | + $selectedIndex = Console::askInt($base.Console::text('Enter desired index then press [Enter] to run sample > ', 'white')); |
|
| 164 | 164 | $index = getIndex(); |
| 165 | 165 | |
| 166 | - switch($selectedIndex){ |
|
| 166 | + switch ($selectedIndex) { |
|
| 167 | 167 | case 0: |
| 168 | 168 | Console::log(); |
| 169 | 169 | exit(); |
@@ -174,39 +174,39 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $title = $index[$selectedIndex][0]; |
| 176 | 176 | $fileName = $index[$selectedIndex][2]; |
| 177 | - $filePath = __DIR__ . '/'. $fileName; |
|
| 177 | + $filePath = __DIR__.'/'.$fileName; |
|
| 178 | 178 | |
| 179 | 179 | Console::clear(); |
| 180 | 180 | writeHeader(); |
| 181 | 181 | writeSampleHeader($selectedIndex, $title); |
| 182 | 182 | |
| 183 | - Console::log($base . Console::text('Start running [', 'white') . |
|
| 184 | - Console::text( $title, 'lightcyan') . |
|
| 185 | - Console::text('] in file [', 'white') . |
|
| 186 | - Console::text( $fileName, 'lightcyan') . |
|
| 183 | + Console::log($base.Console::text('Start running [', 'white'). |
|
| 184 | + Console::text($title, 'lightcyan'). |
|
| 185 | + Console::text('] in file [', 'white'). |
|
| 186 | + Console::text($fileName, 'lightcyan'). |
|
| 187 | 187 | Console::text(']', 'white')); |
| 188 | 188 | |
| 189 | - if (file_exists($filePath)){ |
|
| 189 | + if (file_exists($filePath)) { |
|
| 190 | 190 | Console::log(); |
| 191 | 191 | include $filePath; |
| 192 | 192 | Console::log(); |
| 193 | - Console::log($base . Console::text('End running [', 'white') . |
|
| 194 | - Console::text( $title, 'lightcyan') . |
|
| 193 | + Console::log($base.Console::text('End running [', 'white'). |
|
| 194 | + Console::text($title, 'lightcyan'). |
|
| 195 | 195 | Console::text(']', 'white')); |
| 196 | - $response = Console::ask($base . Console::text('Do you want to see the code that has been executed? (type y/Y to see the code) > ', 'white')); |
|
| 196 | + $response = Console::ask($base.Console::text('Do you want to see the code that has been executed? (type y/Y to see the code) > ', 'white')); |
|
| 197 | 197 | if (strtoupper($response) === 'Y') { |
| 198 | - Console::log($base . Console::text('The code in file [', 'white') . |
|
| 199 | - Console::text( $fileName, 'lightcyan') . |
|
| 198 | + Console::log($base.Console::text('The code in file [', 'white'). |
|
| 199 | + Console::text($fileName, 'lightcyan'). |
|
| 200 | 200 | Console::text('] is:', 'white')); |
| 201 | 201 | Console::log(); |
| 202 | 202 | |
| 203 | 203 | $lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 204 | 204 | $count = 1; |
| 205 | - foreach($lines as $line){ |
|
| 205 | + foreach ($lines as $line) { |
|
| 206 | 206 | $codeLine = rtrim($line); |
| 207 | 207 | $isComment = substr(ltrim($codeLine), 0, 2) === '//'; |
| 208 | 208 | Console::log( |
| 209 | - Console::pad($count . ' ', 3, ' ', STR_PAD_LEFT) . |
|
| 209 | + Console::pad($count.' ', 3, ' ', STR_PAD_LEFT). |
|
| 210 | 210 | Console::text(Console::pad($codeLine, 150), $isComment ? 'magenta' : 'black', 'white') |
| 211 | 211 | ); |
| 212 | 212 | $count++; |
@@ -214,17 +214,17 @@ discard block |
||
| 214 | 214 | Console::log(); |
| 215 | 215 | } |
| 216 | 216 | } else { |
| 217 | - Console::log($base . Console::text('Error' , 'red')); |
|
| 218 | - Console::log($base . Console::text(' => File missing [' . $fileName . ']' , 'red')); |
|
| 217 | + Console::log($base.Console::text('Error', 'red')); |
|
| 218 | + Console::log($base.Console::text(' => File missing ['.$fileName.']', 'red')); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } else { |
| 222 | - Console::log($base . Console::text('Error:', 'red')); |
|
| 223 | - Console::log($base . Console::text('=> the value you entered is not a valid index number.', 'red')); |
|
| 222 | + Console::log($base.Console::text('Error:', 'red')); |
|
| 223 | + Console::log($base.Console::text('=> the value you entered is not a valid index number.', 'red')); |
|
| 224 | 224 | askIndex(); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - Console::ask($base . Console::text('Press [Enter] to go back to index > ', 'white')); |
|
| 227 | + Console::ask($base.Console::text('Press [Enter] to go back to index > ', 'white')); |
|
| 228 | 228 | goIndex(); |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | \ No newline at end of file |
@@ -1,10 +1,10 @@ discard block |
||
| 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 | 6 | Console::log('Overview:', 'underline', 'bold'); |
| 7 | -Console::log(" Use " . Console::text("Console::askPassword(\$str [\$styles])", 'blue', 'white') . " to ask user to enter a value and return this value.", 'white'); |
|
| 7 | +Console::log(" Use ".Console::text("Console::askPassword(\$str [\$styles])", 'blue', 'white')." to ask user to enter a value and return this value.", 'white'); |
|
| 8 | 8 | Console::log(''); |
| 9 | 9 | Console::log('Tips:', 'underline', 'bold'); |
| 10 | 10 | Console::log(" - you can customize colors (foreground and background) and some styles in same way than with Console::text()", 'green'); |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | Console::log(" - User input are not hidden on windows platform (not supported)", 'red', 'yellow'); |
| 15 | 15 | Console::log(''); |
| 16 | 16 | Console::log('Usage:', 'underline', 'bold'); |
| 17 | -Console::log(' ' . Console::text(Console::pad("\$value = Console::askPassword('Please Enter something (We wont display it, for now...) > ');", 80), 'blue', 'white')); |
|
| 18 | -Console::log(' ' . Console::text(Console::pad("Console::log();", 80), 'blue', 'white')); |
|
| 19 | -Console::log(' ' . Console::text(Console::pad("Console::log('=> the value you entered is [' . Console::text(\$value, 'red') . ']');", 80), 'blue', 'white')); |
|
| 17 | +Console::log(' '.Console::text(Console::pad("\$value = Console::askPassword('Please Enter something (We wont display it, for now...) > ');", 80), 'blue', 'white')); |
|
| 18 | +Console::log(' '.Console::text(Console::pad("Console::log();", 80), 'blue', 'white')); |
|
| 19 | +Console::log(' '.Console::text(Console::pad("Console::log('=> the value you entered is [' . Console::text(\$value, 'red') . ']');", 80), 'blue', 'white')); |
|
| 20 | 20 | Console::log(''); |
| 21 | 21 | Console::log('Sample:', 'underline', 'bold'); |
| 22 | 22 | $value = Console::askPassword('Please Enter something (We wont display it, for now...) > '); |
| 23 | 23 | Console::log(); |
| 24 | -Console::log('=> the value you entered is [' . Console::text($value, 'red') . ']'); |
|
| 25 | 24 | \ No newline at end of file |
| 25 | +Console::log('=> the value you entered is ['.Console::text($value, 'red').']'); |
|
| 26 | 26 | \ No newline at end of file |
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | |
| 20 | 20 | foreach (Console::getStyles()[ 'options' ] as $option => $value){ |
| 21 | 21 | Console::log(' ' . |
| 22 | - Console::tableRow([ |
|
| 23 | - $index => 7, |
|
| 24 | - $option => 15, |
|
| 25 | - "\\033[" . $value .'m' => 15, |
|
| 26 | - Console::text(str_pad('I am a text style={' . $option .'}', 48), $option) => 50 |
|
| 22 | + Console::tableRow([ |
|
| 23 | + $index => 7, |
|
| 24 | + $option => 15, |
|
| 25 | + "\\033[" . $value .'m' => 15, |
|
| 26 | + Console::text(str_pad('I am a text style={' . $option .'}', 48), $option) => 50 |
|
| 27 | 27 | ])); |
| 28 | 28 | Console::log(' '.Console::tableRowEmpty($rowHeaders)); // add blank row between element |
| 29 | 29 | $index++; |
@@ -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 | // the row header |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | $index = 1; |
| 19 | 19 | |
| 20 | -foreach (Console::getStyles()[ 'options' ] as $option => $value){ |
|
| 21 | - Console::log(' ' . |
|
| 20 | +foreach (Console::getStyles()['options'] as $option => $value) { |
|
| 21 | + Console::log(' '. |
|
| 22 | 22 | Console::tableRow([ |
| 23 | 23 | $index => 7, |
| 24 | 24 | $option => 15, |
| 25 | - "\\033[" . $value .'m' => 15, |
|
| 26 | - Console::text(str_pad('I am a text style={' . $option .'}', 48), $option) => 50 |
|
| 25 | + "\\033[".$value.'m' => 15, |
|
| 26 | + Console::text(str_pad('I am a text style={'.$option.'}', 48), $option) => 50 |
|
| 27 | 27 | ])); |
| 28 | 28 | Console::log(' '.Console::tableRowEmpty($rowHeaders)); // add blank row between element |
| 29 | 29 | $index++; |
@@ -1,6 +1,6 @@ discard block |
||
| 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 | 6 | Console::log('Overview:', 'underline', 'bold'); |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | Console::log('Sample code:', 'underline', 'bold'); |
| 17 | 17 | Console::log(''); |
| 18 | -Console::log(' '.Console::text(str_pad('// fake progress loop ', 100),'red', 'white')); |
|
| 18 | +Console::log(' '.Console::text(str_pad('// fake progress loop ', 100), 'red', 'white')); |
|
| 19 | 19 | Console::log(' '.Console::text(str_pad('for ($i=0 ; $i<=10 ; $i++) {', 100), 'black', 'white')); |
| 20 | -Console::log(' '.Console::text(str_pad(' // Overwrite progress message.', 100), 'red', 'white')); |
|
| 21 | -Console::log(' '.Console::text(str_pad(" Console::relog(' I am a progress text... ['.Console::text($\i, 'green') .']% completed');", 100),'black', 'white')); |
|
| 20 | +Console::log(' '.Console::text(str_pad(' // Overwrite progress message.', 100), 'red', 'white')); |
|
| 21 | +Console::log(' '.Console::text(str_pad(" Console::relog(' I am a progress text... ['.Console::text($\i, 'green') .']% completed');", 100), 'black', 'white')); |
|
| 22 | 22 | Console::log(' '.Console::text(str_pad('', 100), 'black', 'white')); |
| 23 | 23 | Console::log(' '.Console::text(str_pad(" // wait for a while, so we see the animation ", 100), 'red', 'white')); |
| 24 | 24 | Console::log(' '.Console::text(str_pad(' usleep(300000);', 100), 'black', 'white')); |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | Console::log('Sample result:', 'underline', 'bold'); |
| 41 | 41 | |
| 42 | 42 | // fake progress message |
| 43 | -for ($i=0 ; $i<=100 ; $i++) { |
|
| 43 | +for ($i = 0; $i <= 100; $i++) { |
|
| 44 | 44 | |
| 45 | 45 | // Overwrite progress message. |
| 46 | - Console::relog(' I am a progress text... ['.Console::text($i, 'green') .']% completed'); |
|
| 46 | + Console::relog(' I am a progress text... ['.Console::text($i, 'green').']% completed'); |
|
| 47 | 47 | |
| 48 | 48 | // wait for a while, so we see the animation |
| 49 | 49 | usleep(100000); |
@@ -59,5 +59,5 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | // Overwrite progress message. |
| 61 | 61 | // note: you may need to use str_pad() method to be sure all previous text is overwritten. |
| 62 | -Console::relog(Console::text('Done!', 'white', 'green', 'underline'). str_pad(' ', 100)); |
|
| 62 | +Console::relog(Console::text('Done!', 'white', 'green', 'underline').str_pad(' ', 100)); |
|
| 63 | 63 | Console::log(''); |
@@ -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 | Console::log(); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | Console::log('Let say we are current window.'); |
| 14 | -Console::log('We will open a new window using ' . Console::text('Console::newWindow()', 'blue', 'white') . ' method.'); |
|
| 14 | +Console::log('We will open a new window using '.Console::text('Console::newWindow()', 'blue', 'white').' method.'); |
|
| 15 | 15 | Console::ask('Press [Enter] to open new window > '); |
| 16 | 16 | |
| 17 | 17 | // *open* new window |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | Console::log(); |
| 26 | 26 | |
| 27 | 27 | |
| 28 | -Console::log('I am in new window. We will restore the window later using ' . Console::text('Console::restoreWindow()', 'blue', 'white') . ' method.' ); |
|
| 28 | +Console::log('I am in new window. We will restore the window later using '.Console::text('Console::restoreWindow()', 'blue', 'white').' method.'); |
|
| 29 | 29 | Console::ask('Press [Enter] to restore >'); |
| 30 | 30 | |
| 31 | 31 | // restore new window |
| 32 | 32 | Console::restoreWindow(); |
| 33 | 33 | |
| 34 | -Console::log('We have now restored the current window using ' . Console::text('Console::restoreWindow()', 'blue', 'white') . ' method'); |
|
| 35 | -Console::log('We will reopen a new window using ' . Console::text('Console::newWindow()', 'blue', 'white') . ' method.'); |
|
| 34 | +Console::log('We have now restored the current window using '.Console::text('Console::restoreWindow()', 'blue', 'white').' method'); |
|
| 35 | +Console::log('We will reopen a new window using '.Console::text('Console::newWindow()', 'blue', 'white').' method.'); |
|
| 36 | 36 | Console::ask('Press [Enter] to open new window > '); |
| 37 | 37 | |
| 38 | 38 | // *open* new window |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | Console::log(Console::text('_____________________________', 'white', 'yellow', 'bold')); |
| 46 | 46 | Console::log(); |
| 47 | 47 | |
| 48 | -Console::log('I am in new window. We will restore the window later using ' . Console::text('Console::restoreWindow()', 'blue', 'white') . ' method.' ); |
|
| 48 | +Console::log('I am in new window. We will restore the window later using '.Console::text('Console::restoreWindow()', 'blue', 'white').' method.'); |
|
| 49 | 49 | Console::ask('Press [Enter] to restore >'); |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | // restore new window |
| 54 | 54 | Console::restoreWindow(); |
| 55 | -Console::log('We have now restored the current window using ' . Console::text('Console::restoreWindow()', 'blue', 'white') . ' method. That\'s all.'); |
|
| 56 | -Console::log('Got it'. Console::text('?', 'green')); |
|
| 55 | +Console::log('We have now restored the current window using '.Console::text('Console::restoreWindow()', 'blue', 'white').' method. That\'s all.'); |
|
| 56 | +Console::log('Got it'.Console::text('?', 'green')); |
|