public static
string
|
#
color( string $fgcolor, string $style, string $bgcolor )
Create ANSI-control codes for text foreground and background colors, and
styling.
Create ANSI-control codes for text foreground and background colors, and
styling.
Parameters
- $fgcolor
string $fgcolor Text foreground color
- $style
string $style Text style
- $bgcolor
string $bgcolor Text background color
Returns
string ANSI-control code
|
public static
mixed
|
#
colorize( mixed $text, boolean $color = true )
aken from PEAR's Console_Color:
aken from PEAR's Console_Color:
Converts colorcodes in the format %y (for yellow) into ansi-control codes.
The conversion table is: ('bold' meaning 'light' on some terminals). It's almost
the same conversion table irssi uses.
text text background
------------------------------------------------
%k %K %0 black dark grey black
%r %R %1 red bold red red
%g %G %2 green bold green green
%y %Y %3 yellow bold yellow yellow
%b %B %4 blue bold blue blue
%m %M %5 magenta bold magenta magenta
%p %P magenta (think: purple)
%c %C %6 cyan bold cyan cyan
%w %W %7 white bold white white
%F Blinking, Flashing
%U Underline
%8 Reverse
%_,%9 Bold
%n Resets the color
%% A single %
First param is the string to convert, second is an optional flag if colors
should be used. It defaults to true, if set to false, the colorcodes will just
be removed (And %% will be transformed into %)
Parameters
- $text
mixed $text
- $color
boolean $color
Returns
mixed
|
public static
string
|
#
decolorize( string $text )
Strips a string from color specifiers.
Strips a string from color specifiers.
Parameters
- $text
string $text String to strip
Returns
string
|
public static
string
|
#
strip( string $text )
Strips a string of ansi-control codes.
Strips a string of ansi-control codes.
Parameters
- $text
string $text String to strip
Returns
string
|
public static
string
|
#
stdin( boolean $raw = false )
Gets input from STDIN and returns a string right-trimmed for EOLs.
Gets input from STDIN and returns a string right-trimmed for EOLs.
Parameters
- $raw
boolean $raw If set to true, returns the raw string without trimming
Returns
string
|
public static
integer|false
|
#
stdout( string $text, boolean $raw = false )
Prints text to STDOUT.
Parameters
- $text
string $text
- $raw
boolean $raw
Returns
integer|false Number of bytes printed or false on error
|
public static
integer|false
|
#
stderr( string $text, boolean $raw = false )
Prints text to STDERR.
Parameters
- $text
string $text
- $raw
boolean $raw
Returns
integer|false Number of bytes printed or false on error
|
public static
integer|false
|
#
error( string $text = null, boolean $raw = false )
Prints text to STDERR appended with a PHP_EOL.
Prints text to STDERR appended with a PHP_EOL.
Parameters
- $text
string $text
- $raw
boolean $raw
Returns
integer|false Number of bytes printed or false on error
|
public static
string
|
#
input( string $prompt = null )
Asks the user for input. Ends when the user types a PHP_EOL. Optionally
provide a prompt.
Asks the user for input. Ends when the user types a PHP_EOL. Optionally
provide a prompt.
Parameters
- $prompt
string $prompt String prompt (optional)
Returns
string User input
|
public static
integer|false
|
#
output( string $text = null, boolean $raw = false )
Prints text to STDOUT appended with a PHP_EOL.
Prints text to STDOUT appended with a PHP_EOL.
Parameters
- $text
string $text
- $raw
boolean $raw
Returns
integer|false Number of bytes printed or false on error
|
public static
string
|
#
prompt( string $text, array $options = array() )
Prompts the user for input
Prompts the user for input
Parameters
- $text
string $text Prompt string
- $options
array $options Set of options
Returns
string
|
public static
boolean
|
#
confirm( string $text )
Asks the user for a simple yes/no confirmation.
Asks the user for a simple yes/no confirmation.
Parameters
- $text
string $text Prompt string
Returns
boolean Either true or false
|
public static
string
|
#
select( string $text, array $options = array() )
Gives the user an option to choose from. Giving '?' as an input will show a
list of options to choose from and their explanations.
Gives the user an option to choose from. Giving '?' as an input will show a
list of options to choose from and their explanations.
Parameters
- $text
string $text Prompt string
- $options
array $options Key-value array of options to choose from
Returns
string An option character the user chose
|
public static
boolean|integer
|
#
work( Closure $callable )
Execute a Closure as another process in the background while showing a status
update. The status update can be an indefinite spinner or a string periodically
sent from the background process, depending on whether the provided Closure
object has a $socket parameter or not. Messaging to the main process is done by
socket_* functions. The return value is either the return value of the
background process, or false if the process fork failed.
Execute a Closure as another process in the background while showing a status
update. The status update can be an indefinite spinner or a string periodically
sent from the background process, depending on whether the provided Closure
object has a $socket parameter or not. Messaging to the main process is done by
socket_* functions. The return value is either the return value of the
background process, or false if the process fork failed.
Parameters
- $callable
callable $callable Closure object
Returns
boolean|integer
Throws
|