@@ -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 | } |
@@ -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')); |
@@ -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 |
@@ -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')); |
@@ -1,23 +1,23 @@ |
||
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("string Console::ask ( string \$str [, \$styles] )", 'blue', 'white') . "to ask something to user in the console."); |
|
7 | +Console::log(" - Use ".Console::text("string Console::ask ( string \$str [, \$styles] )", 'blue', 'white')."to ask something to user in the console."); |
|
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()", 'lightmagenta'); |
11 | 11 | Console::log(" and Console::log() methods.", 'lightmagenta'); |
12 | 12 | Console::log(''); |
13 | 13 | Console::log('Usage:', 'underline', 'bold'); |
14 | -Console::log(' '. Console::text(Console::pad("\$value1 = Console::ask('Please enter something > ');", 90), 'blue', 'white')); |
|
15 | -Console::log(' '. Console::text(Console::pad("// or);", 90), 'green', 'white')); |
|
16 | -Console::log(' '. Console::text(Console::pad("\$value2 = Console::ask('Please enter something > ', 'red', 'white', 'underline');", 90), 'blue', 'white')); |
|
14 | +Console::log(' '.Console::text(Console::pad("\$value1 = Console::ask('Please enter something > ');", 90), 'blue', 'white')); |
|
15 | +Console::log(' '.Console::text(Console::pad("// or);", 90), 'green', 'white')); |
|
16 | +Console::log(' '.Console::text(Console::pad("\$value2 = Console::ask('Please enter something > ', 'red', 'white', 'underline');", 90), 'blue', 'white')); |
|
17 | 17 | Console::log(''); |
18 | 18 | |
19 | 19 | $value = Console::ask('Please enter something > '); |
20 | -Console::log('=> the value you entered is [' . Console::text($value, 'yellow') . ']'); |
|
20 | +Console::log('=> the value you entered is ['.Console::text($value, 'yellow').']'); |
|
21 | 21 | |
22 | 22 | $value2 = Console::ask('Please enter something > ', 'red', 'white', 'underline'); |
23 | -Console::log('=> the value you entered is [' . Console::text($value2, 'yellow') . ']'); |
|
24 | 23 | \ No newline at end of file |
24 | +Console::log('=> the value you entered is ['.Console::text($value2, 'yellow').']'); |
|
25 | 25 | \ No newline at end of file |