1 | <?php |
||
10 | class Cli |
||
11 | { |
||
12 | /** |
||
13 | * @const ERR_COLOR_NOT_AVAILABLE Exception code if the color is not |
||
14 | * available. |
||
15 | */ |
||
16 | const ERR_COLOR_NOT_AVAILABLE = 1201001; |
||
17 | |||
18 | /** |
||
19 | * @const ERR_STYLE_NOT_AVAILABLE Exception code if the style is not |
||
20 | * available. |
||
21 | */ |
||
22 | const ERR_STYLE_NOT_AVAILABLE = 1201002; |
||
23 | |||
24 | /** |
||
25 | * @const FLUSH_AUTO Value to use on $flushMethod property to automaticaly |
||
26 | * call the method ob_flush into function displayMsg and displayMsgNoNL |
||
27 | */ |
||
28 | const FLUSH_AUTO = 'auto'; |
||
29 | |||
30 | /** |
||
31 | * @const FLUSH_MANUAL Value to use on $flushMethod property to NOT |
||
32 | * automaticaly call the method ob_flush into function displayMsg |
||
33 | * and displayMsgNL |
||
34 | */ |
||
35 | const FLUSH_MANUAL = 'manual'; |
||
36 | |||
37 | /** |
||
38 | * @var string $callObFlush (default: self::FLUSH_AUTO) Define if the |
||
39 | * method ob_flush is called or not into the method displayMsg |
||
40 | * and displayMsgNL |
||
41 | */ |
||
42 | public static $callObFlush = self::FLUSH_AUTO; |
||
43 | |||
44 | /** |
||
45 | * Display a message in the console without a line break |
||
46 | * If only the first parameter is passed, the colors will be those |
||
47 | * currently used in the console |
||
48 | * |
||
49 | * @param string $msg Message to display |
||
50 | * @param string $colorTxt (default "white") Text color |
||
51 | * @param string $colorBg (default "black") Background color |
||
52 | * @param string $style (default "normal") Style for the message (bold etc) |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | public static function displayMsg( |
||
85 | |||
86 | /** |
||
87 | * Display a message in the console with a line break |
||
88 | * If only the first parameter is passed, the colors will be those |
||
89 | * currently used in the console |
||
90 | * |
||
91 | * @param string $msg Message to display |
||
92 | * @param string $colorTxt (default "white") Text color |
||
93 | * @param string $colorBg (default "black") Background color |
||
94 | * @param string $style (default "normal") Style for the message (bold etc) |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | public static function displayMsgNL( |
||
113 | |||
114 | /** |
||
115 | * Convert text color to shell value |
||
116 | * |
||
117 | * @param string $color The human color text |
||
118 | * @param string $type ("txt"|"bg") If the color is for text or background |
||
119 | * |
||
120 | * @return integer |
||
121 | * |
||
122 | * @throws Exception If the color is not available |
||
123 | */ |
||
124 | protected static function colorForShell($color, $type) |
||
152 | |||
153 | /** |
||
154 | * Convert a human style text to shell value |
||
155 | * |
||
156 | * @param string $style The style value |
||
157 | * |
||
158 | * @return integer |
||
159 | * |
||
160 | * @throws Exception If the style is not available |
||
161 | */ |
||
162 | protected static function styleForShell($style) |
||
185 | |||
186 | /** |
||
187 | * Override the PHP function getopt to always use the short "f:". |
||
188 | * If "f:" is not present, nothing is returned (#79) |
||
189 | * |
||
190 | * @link http://php.net/manual/en/function.getopt.php |
||
191 | * |
||
192 | * @param string $options Each character in this string will be used as |
||
193 | * option characters and matched against options passed to the script |
||
194 | * starting with a single hyphen (-). For example, an option string "x" |
||
195 | * recognizes an option -x. Only a-z, A-Z and 0-9 are allowed. |
||
196 | * @param array $longopts (default []) An array of options. |
||
197 | * Each element in this array will be used as option strings and matched |
||
198 | * against options passed to the script starting with two hyphens (--). |
||
199 | * For example, an longopts element "opt" recognizes an option --opt. |
||
200 | * |
||
201 | * @return boolean|array |
||
202 | */ |
||
203 | public static function getopt($options , $longopts = []) |
||
211 | } |
||
212 |