@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'magenta' => '35', |
36 | 36 | 'cyan' => '36', |
37 | 37 | 'lightgray' => '37', |
38 | - 'default' => '39', // your default color |
|
38 | + 'default' => '39', // your default color |
|
39 | 39 | 'darkgray' => '90', |
40 | 40 | 'lightred' => '91', |
41 | 41 | 'lightgreen' => '92', |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | * @var array |
82 | 82 | */ |
83 | 83 | protected static $options = array( |
84 | - 'none' => '0', // reset all styles |
|
85 | - 'bold' => '1', // |
|
84 | + 'none' => '0', // reset all styles |
|
85 | + 'bold' => '1', // |
|
86 | 86 | 'dim' => '2', |
87 | 87 | 'underlined' => '4', |
88 | 88 | 'blink' => '5', |
89 | - 'reverse' => '7', // reverse foreground/background color |
|
89 | + 'reverse' => '7', // reverse foreground/background color |
|
90 | 90 | ); |
91 | 91 | |
92 | 92 | /** |
@@ -125,39 +125,39 @@ discard block |
||
125 | 125 | array_shift($args); |
126 | 126 | |
127 | 127 | // |
128 | - switch($command){ |
|
128 | + switch ($command) { |
|
129 | 129 | |
130 | 130 | // **************************************** |
131 | 131 | // Get methods (return string) |
132 | 132 | // **************************************** |
133 | 133 | |
134 | 134 | case'text': |
135 | - return self::getCliString($str, $args); // get formatted text |
|
135 | + return self::getCliString($str, $args); // get formatted text |
|
136 | 136 | |
137 | 137 | // **************************************** |
138 | 138 | // Print methods (echo and return null) |
139 | 139 | // **************************************** |
140 | 140 | |
141 | 141 | case'print': |
142 | - echo (self::getCliString($str, $args)); // print text |
|
142 | + echo (self::getCliString($str, $args)); // print text |
|
143 | 143 | break; |
144 | 144 | |
145 | 145 | case'log': |
146 | - echo (self::getCliString($str, $args) . self::$EOF ); // print text + newline |
|
146 | + echo (self::getCliString($str, $args).self::$EOF); // print text + newline |
|
147 | 147 | break; |
148 | 148 | |
149 | 149 | case'relog': |
150 | 150 | // overwrite last line (cursor stays at the beginning) |
151 | - echo (self::getCliString($str ."\r", $args)); |
|
151 | + echo (self::getCliString($str."\r", $args)); |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | case'overwrite': |
155 | 155 | // Overwrite last x printed line (add trailing new lines) |
156 | 156 | // text could be one line string, or array of lines |
157 | 157 | $text = is_array($str) ? implode(PHP_EOL, $str) : $str; |
158 | - $overwriteIndex = is_array($str) ? count($str) : 1; |
|
158 | + $overwriteIndex = is_array($str) ? count($str) : 1; |
|
159 | 159 | // https://stackoverflow.com/questions/11283625/overwrite-last-line-on-terminal |
160 | - echo ("\033[". $overwriteIndex ."A\033[K".self::getCliString($text, $args).self::$EOF); |
|
160 | + echo ("\033[".$overwriteIndex."A\033[K".self::getCliString($text, $args).self::$EOF); |
|
161 | 161 | |
162 | 162 | break; |
163 | 163 | |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | // ***************************************** |
167 | 167 | |
168 | 168 | case'ask': |
169 | - echo (self::getCliString($str, $args)); // print question |
|
170 | - return trim(fgets(STDIN)); // reads and return one line from STDIN |
|
169 | + echo (self::getCliString($str, $args)); // print question |
|
170 | + return trim(fgets(STDIN)); // reads and return one line from STDIN |
|
171 | 171 | |
172 | 172 | case'askPassword': |
173 | - self::hideInput(); // hide |
|
174 | - echo (self::getCliString($str, $args)); // print question |
|
175 | - $line= trim(fgets(STDIN)); // reads one line from STDIN |
|
176 | - self::restoreInput(); // restore |
|
177 | - return $line; // return line |
|
173 | + self::hideInput(); // hide |
|
174 | + echo (self::getCliString($str, $args)); // print question |
|
175 | + $line = trim(fgets(STDIN)); // reads one line from STDIN |
|
176 | + self::restoreInput(); // restore |
|
177 | + return $line; // return line |
|
178 | 178 | |
179 | 179 | case 'askInt': |
180 | - echo (self::getCliString($str, $args)); // print question |
|
181 | - fscanf(STDIN, "%d\n", $number); // reads number from STDIN |
|
180 | + echo (self::getCliString($str, $args)); // print question |
|
181 | + fscanf(STDIN, "%d\n", $number); // reads number from STDIN |
|
182 | 182 | return (is_int($number) ? $number : false); // return int value or false |
183 | 183 | } |
184 | 184 | |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | $bgcolor, |
197 | 197 | $background = 'darkgray', |
198 | 198 | $progressLenght = 40, |
199 | - $pendingSign = ' ', |
|
200 | - $progressSign = ' ', |
|
199 | + $pendingSign = ' ', |
|
200 | + $progressSign = ' ', |
|
201 | 201 | $withPurcent = true |
202 | - ){ |
|
203 | - $perc = min(100,$percent); |
|
204 | - $start = round($progressLenght * $perc / 100); |
|
202 | + ) { |
|
203 | + $perc = min(100, $percent); |
|
204 | + $start = round($progressLenght*$perc/100); |
|
205 | 205 | |
206 | - return ($withPurcent ? Console::text(Console::pad($perc . '% ', 5, ' ', STR_PAD_LEFT), $color) : ''). |
|
207 | - Console::text(Console::pad('', $start, $progressSign), 'white', $bgcolor) . |
|
208 | - Console::text(Console::pad('', $progressLenght - $start, $pendingSign), 'black', $background) ; |
|
206 | + return ($withPurcent ? Console::text(Console::pad($perc.'% ', 5, ' ', STR_PAD_LEFT), $color) : ''). |
|
207 | + Console::text(Console::pad('', $start, $progressSign), 'white', $bgcolor). |
|
208 | + Console::text(Console::pad('', $progressLenght-$start, $pendingSign), 'black', $background); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected static function getCliString(string $str, array $arguments = []) |
222 | 222 | { |
223 | - if (empty($arguments)){ |
|
223 | + if (empty($arguments)) { |
|
224 | 224 | return $str; |
225 | 225 | } |
226 | 226 | |
@@ -233,25 +233,25 @@ discard block |
||
233 | 233 | foreach ($arguments as $argument) { |
234 | 234 | |
235 | 235 | // it's a color? |
236 | - if(!$hasColor && isset(self::$foregroundColors[$argument])){ |
|
236 | + if (!$hasColor && isset(self::$foregroundColors[$argument])) { |
|
237 | 237 | $cliArgs[] = self::$foregroundColors[$argument]; |
238 | 238 | $hasColor = true; |
239 | 239 | |
240 | 240 | // it's a backcolor? |
241 | - } elseif ($hasColor && !$hasBackColor && isset(self::$backgroundColors[$argument])){ |
|
241 | + } elseif ($hasColor && !$hasBackColor && isset(self::$backgroundColors[$argument])) { |
|
242 | 242 | $cliArgs[] = self::$backgroundColors[$argument]; |
243 | 243 | $hasBackColor = true; |
244 | 244 | |
245 | 245 | // or it's an option? |
246 | - } elseif (isset(self::$options[$argument])){ |
|
246 | + } elseif (isset(self::$options[$argument])) { |
|
247 | 247 | $cliArgs[] = self::$options[$argument]; |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Add string and end coloring |
252 | 252 | // todo \e[0m |
253 | - $coloredString .= "\033[" . implode(';',$cliArgs) .'m'; |
|
254 | - $coloredString .= $str . "\033[0m"; |
|
253 | + $coloredString .= "\033[".implode(';', $cliArgs).'m'; |
|
254 | + $coloredString .= $str."\033[0m"; |
|
255 | 255 | return $coloredString; |
256 | 256 | } |
257 | 257 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public static function askPassword() |
337 | 337 | { |
338 | - return self::cmd('askPassword',func_get_args()); |
|
338 | + return self::cmd('askPassword', func_get_args()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public static function log() |
354 | 354 | { |
355 | - self::cmd('log',func_get_args()); |
|
355 | + self::cmd('log', func_get_args()); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | */ |
370 | 370 | public static function relog() |
371 | 371 | { |
372 | - self::cmd('relog',func_get_args()); |
|
372 | + self::cmd('relog', func_get_args()); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | public static function overwrite() |
388 | 388 | { |
389 | - self::cmd('overwrite',func_get_args()); |
|
389 | + self::cmd('overwrite', func_get_args()); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public static function pad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT) |
405 | 405 | { |
406 | - $diff = $padLength - mb_strlen(preg_replace('#\\033\[[[0-9;*]{1,}m#', '', $input)); |
|
406 | + $diff = $padLength-mb_strlen(preg_replace('#\\033\[[[0-9;*]{1,}m#', '', $input)); |
|
407 | 407 | |
408 | - if ($diff > 0){ |
|
409 | - switch ($padType){ |
|
408 | + if ($diff > 0) { |
|
409 | + switch ($padType) { |
|
410 | 410 | |
411 | 411 | case STR_PAD_RIGHT: |
412 | - return $input . str_repeat($padString, $diff); |
|
412 | + return $input.str_repeat($padString, $diff); |
|
413 | 413 | |
414 | 414 | case STR_PAD_LEFT: |
415 | - return str_repeat($padString, $diff ) . $input; |
|
415 | + return str_repeat($padString, $diff).$input; |
|
416 | 416 | |
417 | 417 | case STR_PAD_BOTH: |
418 | 418 | $padLeft = round(($diff)/2); |
419 | - return str_repeat($padString, $padLeft) . $input . str_repeat($padString, $diff - $padLeft); |
|
419 | + return str_repeat($padString, $padLeft).$input.str_repeat($padString, $diff-$padLeft); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | return $input; |
@@ -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 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | Console::log(" - you may need to use " . Console::text("php str_pad()", 'lightblue', 'underlined') . " method to be sure all previous text is overwritten."); |
12 | 12 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
13 | 13 | Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
14 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
14 | + ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
15 | 15 | Console::log(); |
16 | 16 | Console::log(' '. Console::text('Sample code:', 'underlined', 'bold')); |
17 | 17 | Console::log(); |
@@ -1,24 +1,24 @@ 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(); |
6 | -Console::log(' '. Console::text('Overview:', 'underlined', 'bold')); |
|
7 | -Console::log(" - Use " . Console::text("Console::relog()", 'lightblue', 'underlined') . " to write temporary output to be overwritten later.", 'white'); |
|
6 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
7 | +Console::log(" - Use ".Console::text("Console::relog()", 'lightblue', 'underlined')." to write temporary output to be overwritten later.", 'white'); |
|
8 | 8 | Console::log(); |
9 | 9 | |
10 | -Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
|
11 | -Console::log(" - you may need to use " . Console::text("php str_pad()", 'lightblue', 'underlined') . " method to be sure all previous text is overwritten."); |
|
10 | +Console::log(' '.Console::text('Tips:', 'underlined', 'bold')); |
|
11 | +Console::log(" - you may need to use ".Console::text("php str_pad()", 'lightblue', 'underlined')." method to be sure all previous text is overwritten."); |
|
12 | 12 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
13 | -Console::log(' with ' . Console::text("Console::text()", 'lightblue', 'underlined') . |
|
14 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
13 | +Console::log(' with '.Console::text("Console::text()", 'lightblue', 'underlined'). |
|
14 | + ' and '.Console::text("Console::log()", 'lightblue', 'underlined').' methods.'); |
|
15 | 15 | Console::log(); |
16 | -Console::log(' '. Console::text('Sample code:', 'underlined', 'bold')); |
|
16 | +Console::log(' '.Console::text('Sample code:', 'underlined', 'bold')); |
|
17 | 17 | Console::log(); |
18 | -Console::log(' '.Console::text(str_pad('// fake progress loop ', 100),'green')); |
|
18 | +Console::log(' '.Console::text(str_pad('// fake progress loop ', 100), 'green')); |
|
19 | 19 | Console::log(' '.Console::text(str_pad('for ($i=0 ; $i<=10 ; $i++) {', 100), 'lightgray')); |
20 | -Console::log(' '.Console::text(str_pad(' // Overwrite progress message.', 100), 'green')); |
|
21 | -Console::log(' '.Console::text(str_pad(" Console::relog(' I am a progress text... ['.Console::text($\i, 'green') .']% completed');", 100),'lightgray')); |
|
20 | +Console::log(' '.Console::text(str_pad(' // Overwrite progress message.', 100), 'green')); |
|
21 | +Console::log(' '.Console::text(str_pad(" Console::relog(' I am a progress text... ['.Console::text($\i, 'green') .']% completed');", 100), 'lightgray')); |
|
22 | 22 | Console::log(' '.Console::text(str_pad(" // wait for a while, so we see the animation ", 100), 'green')); |
23 | 23 | Console::log(' '.Console::text(str_pad(' usleep(300000);', 100), 'lightgray')); |
24 | 24 | Console::log(' '.Console::text(str_pad('}', 100), 'lightgray')); |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | Console::log(' '.Console::text(str_pad("// note: you may need to use str_pad() method to be sure all previous text is overwritten", 100), 'green')); |
36 | 36 | Console::log(' '.Console::text(str_pad("Console::relog(Console::text('Done!', 'white', 'green', 'underlined'). str_pad(' ', 100);", 100), 'lightgray')); |
37 | 37 | Console::log(); |
38 | -Console::log(' ' .' '.Console::text('Sample result:', 'underlined', 'bold')); |
|
38 | +Console::log(' '.' '.Console::text('Sample result:', 'underlined', 'bold')); |
|
39 | 39 | // ----------------- |
40 | 40 | // sample start here |
41 | 41 | // ----------------- |
42 | 42 | |
43 | 43 | // fake progress message |
44 | -for ($i=0 ; $i<=100 ; $i++) { |
|
44 | +for ($i = 0; $i <= 100; $i++) { |
|
45 | 45 | |
46 | 46 | // Overwrite progress message. |
47 | - Console::relog(' I am a progress text... ['.Console::text($i, 'green') .']% completed'); |
|
47 | + Console::relog(' I am a progress text... ['.Console::text($i, 'green').']% completed'); |
|
48 | 48 | |
49 | 49 | // wait for a while, so we see the animation |
50 | 50 | usleep(100000); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | // Overwrite progress message. |
62 | 62 | // note: you may need to use str_pad() method to be sure all previous text is overwritten. |
63 | -Console::relog(Console::text(' Done!', 'white', 'green', 'underlined'). str_pad(' ', 100)); |
|
63 | +Console::relog(Console::text(' Done!', 'white', 'green', 'underlined').str_pad(' ', 100)); |
|
64 | 64 | Console::log(''); |
65 | 65 | |
66 | 66 | ?> |
@@ -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 | ?> |
@@ -1,5 +1,5 @@ |
||
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::restoreWindow(); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | Console::log(" - " . Console::text('No need', 'underlined', 'bold') ." to use " . Console::text("php str_pad()", 'lightblue', 'underlined') . " method like with " .Console::text("Console::relog()", 'lightblue', 'underlined') ); |
13 | 13 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
14 | 14 | Console::log(' ' .Console::text("Console::text()", 'lightblue', 'underlined') . |
15 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
15 | + ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
16 | 16 | Console::log(); |
17 | 17 | Console::log(' '. Console::text('Basic usage:', 'underlined', 'bold')); |
18 | 18 | Console::log(); |
@@ -1,32 +1,32 @@ |
||
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 | |
6 | -Console::log(' '. Console::text('Overview:', 'underlined', 'bold')); |
|
7 | -Console::log(' '. Console::text('- Using ','white').Console::text("Console::overwrite()", 'lightblue', 'underlined').Console::text('you can overwrite more than one row.', 'white')); |
|
8 | -Console::log(' '. Console::text('To overwrite the 2 last printed rows, you need to pass an array of 2 ','white').Console::text("string", 'lightblue', '').' '. Console::text('.', 'white')); |
|
6 | +Console::log(' '.Console::text('Overview:', 'underlined', 'bold')); |
|
7 | +Console::log(' '.Console::text('- Using ', 'white').Console::text("Console::overwrite()", 'lightblue', 'underlined').Console::text('you can overwrite more than one row.', 'white')); |
|
8 | +Console::log(' '.Console::text('To overwrite the 2 last printed rows, you need to pass an array of 2 ', 'white').Console::text("string", 'lightblue', '').' '.Console::text('.', 'white')); |
|
9 | 9 | Console::log(); |
10 | 10 | |
11 | -Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
|
12 | -Console::log(" - " . Console::text('No need', 'underlined', 'bold') ." to use " . Console::text("php str_pad()", 'lightblue', 'underlined') . " method like with " .Console::text("Console::relog()", 'lightblue', 'underlined') ); |
|
11 | +Console::log(' '.Console::text('Tips:', 'underlined', 'bold')); |
|
12 | +Console::log(" - ".Console::text('No need', 'underlined', 'bold')." to use ".Console::text("php str_pad()", 'lightblue', 'underlined')." method like with ".Console::text("Console::relog()", 'lightblue', 'underlined')); |
|
13 | 13 | Console::log(" - You can customize colors (foreground and background) and some styles in same way than "); |
14 | -Console::log(' ' .Console::text("Console::text()", 'lightblue', 'underlined') . |
|
15 | - ' and ' . Console::text("Console::log()", 'lightblue', 'underlined'). ' methods.'); |
|
14 | +Console::log(' '.Console::text("Console::text()", 'lightblue', 'underlined'). |
|
15 | + ' and '.Console::text("Console::log()", 'lightblue', 'underlined').' methods.'); |
|
16 | 16 | Console::log(); |
17 | -Console::log(' '. Console::text('Basic usage:', 'underlined', 'bold')); |
|
17 | +Console::log(' '.Console::text('Basic usage:', 'underlined', 'bold')); |
|
18 | 18 | Console::log(); |
19 | 19 | Console::log(" Console::log('I am a real log line, with \\n, but I will be erased');"); |
20 | 20 | Console::log(" Console::log('I am another real log line, with \\n, but I will be erased');"); |
21 | 21 | Console::log(" Console::overwrite('I am new real line.');"); |
22 | 22 | Console::log(); |
23 | -Console::log(' ' .Console::text('Sample code:', 'underlined', 'bold')); |
|
23 | +Console::log(' '.Console::text('Sample code:', 'underlined', 'bold')); |
|
24 | 24 | Console::log(); |
25 | 25 | // ----------------- |
26 | 26 | // sample start here |
27 | 27 | // ----------------- |
28 | 28 | |
29 | -$msg1 = Console::text(' [*]', 'blue'). Console::text(' Tortoise vs Hare Race will starting. Place your bets! ...', 'white'); |
|
29 | +$msg1 = Console::text(' [*]', 'blue').Console::text(' Tortoise vs Hare Race will starting. Place your bets! ...', 'white'); |
|
30 | 30 | $msg2 = Console::text(' [*]', 'blue').Console::text(' |
@@ -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 | } |
@@ -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,21 +10,21 @@ discard block |
||
10 | 10 | $cols = Console::getColumns(); |
11 | 11 | $middle = round($lines/2); |
12 | 12 | |
13 | -for ($i= 1; $i <= $lines ; $i++){ |
|
13 | +for ($i = 1; $i <= $lines; $i++) { |
|
14 | 14 | |
15 | - switch($i){ |
|
16 | - case $middle -10: Console::log(Console::pad(" /", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
17 | - case $middle -9: Console::log(Console::pad(" /", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
18 | - case $middle -8: Console::log(Console::pad(" /", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
19 | - case $middle -7: Console::log(Console::pad(" | o", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
20 | - case $middle -6: Console::log(Console::pad(" |", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
21 | - case $middle -5: Console::log(Console::pad(" | o", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
22 | - case $middle -4: Console::log(Console::pad(" \\", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
23 | - case $middle -3: Console::log(Console::pad(" \\", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
24 | - case $middle -2: Console::log(Console::pad(" \\", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
25 | - case $middle +1: Console::log(Console::pad(" Houston, we've had a problem...", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
26 | - case $middle +2: Console::log(Console::pad(" The screen is blue. The screen is blue. The screen is blue. The screen is blue. The screen is blue. ", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
27 | - case $middle +3: Console::log(Console::pad(" The screen is blue. The screen is blue. The screen is blue. The screen is blue. The screen is blue. ", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
15 | + switch ($i) { |
|
16 | + case $middle-10: Console::log(Console::pad(" /", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
17 | + case $middle-9: Console::log(Console::pad(" /", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
18 | + case $middle-8: Console::log(Console::pad(" /", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
19 | + case $middle-7: Console::log(Console::pad(" | o", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
20 | + case $middle-6: Console::log(Console::pad(" |", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
21 | + case $middle-5: Console::log(Console::pad(" | o", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
22 | + case $middle-4: Console::log(Console::pad(" \\", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
23 | + case $middle-3: Console::log(Console::pad(" \\", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
24 | + case $middle-2: Console::log(Console::pad(" \\", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
25 | + case $middle+1: Console::log(Console::pad(" Houston, we've had a problem...", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
26 | + case $middle+2: Console::log(Console::pad(" The screen is blue. The screen is blue. The screen is blue. The screen is blue. The screen is blue. ", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
27 | + case $middle+3: Console::log(Console::pad(" The screen is blue. The screen is blue. The screen is blue. The screen is blue. The screen is blue. ", $cols, ' ', STR_PAD_RIGHT), 'white', 'blue'); break; |
|
28 | 28 | case $lines: Console::askInt(Console::pad('Press something to stop damage your eyes > ', $cols, ' ', STR_PAD_LEFT), 'white', 'blue'); break; |
29 | 29 | default: Console::log(Console::pad(' ', $cols), 'white', 'blue'); |
30 | 30 | } |
@@ -1,21 +1,21 @@ |
||
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 |
6 | -$rowHeaders = [ 'Style name' => 15, 'ANSI Code' => 15, 'Sample output' => 50 ]; |
|
6 | +$rowHeaders = ['Style name' => 15, 'ANSI Code' => 15, 'Sample output' => 50]; |
|
7 | 7 | Console::log(' '.Console::tableRowSeparator($rowHeaders)); |
8 | 8 | Console::log(' '.Console::tableRow($rowHeaders)); |
9 | 9 | Console::log(' '.Console::tableRowSeparator($rowHeaders)); |
10 | 10 | |
11 | 11 | // enum styles |
12 | 12 | $index = 1; |
13 | -foreach (Console::getStyles()[ 'options' ] as $option => $value){ |
|
14 | - Console::log(' ' . |
|
13 | +foreach (Console::getStyles()['options'] as $option => $value) { |
|
14 | + Console::log(' '. |
|
15 | 15 | Console::tableRow([ |
16 | 16 | $option => 15, |
17 | - "\\033[" . $value .'m' => 15, |
|
18 | - Console::text('I am a text style={' . $option .'}', $option) => 50 |
|
17 | + "\\033[".$value.'m' => 15, |
|
18 | + Console::text('I am a text style={'.$option.'}', $option) => 50 |
|
19 | 19 | ])); |
20 | 20 | $index++; |
21 | 21 | } |