PHP Class Horde_Cli, horde

Copyright 2003-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Chuck Hagenbuch ([email protected])
Author: Jan Schneider ([email protected])
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство Type Description
$_blue_end
$_blue_start
$_bold_end string The string to mark the end of bold text.
$_bold_start string The string to mark the beginning of bold text.
$_clearscreen string The string to use for clearing the screen.
$_console boolean Are we running on a console?
$_green_end
$_green_start
$_indent string The indent string to use.
$_newline string The newline string to use.
$_red_end string The strings to mark the end of coloured text.
$_red_start string The strings to mark the beginning of coloured text.
$_terminalBackgrounds array Terminal background color codes. Not used yet.
$_terminalForegrounds array Terminal foreground color codes. Not used yet.
$_yellow_end
$_yellow_start

Méthodes publiques

Méthode Description
__construct ( ) Detect the current environment (web server or console) and sets internal values accordingly.
blue ( string $text ) : string Returns a blue version of $text.
bold ( string $text ) : string Returns a bold version of $text.
clearScreen ( ) Clears the entire screen, if possible.
fatal ( mixed $error ) Displays a fatal error message.
green ( string $text ) : string Returns a green version of $text.
indent ( string $text ) : string Returns the indented string.
init ( ) : Horde_Cli CLI scripts shouldn't timeout, so try to set the time limit to none. Also initialize a few variables in $_SERVER that aren't present from the CLI.
message ( $message, string $type = 'cli.message' ) Displays a message.
passwordPrompt ( string $prompt ) : string Interactively prompts for input without echoing to the terminal.
prompt ( string $prompt, array $choices = null, string $default = null ) : mixed Prompts for a user response.
readStdin ( ) : string Reads everything that is sent through standard input and returns it as a single string.
red ( string $text ) : string Returns a red version of $text.
runningFromCLI ( ) : boolean Make sure we're being called from the command line, and not via the web.
shutdown ( ) Destroys any session on script end.
writeln ( string $text = '', boolean $pre = false ) Prints $text on a single line.
yellow ( string $text ) : string Returns a yellow version of $text.

Method Details

__construct() public méthode

Use init() if you also want to set environment variables that may be missing in a CLI environment.
public __construct ( )

blue() public méthode

Returns a blue version of $text.
public blue ( string $text ) : string
$text string The text to print in blue.
Résultat string The blue text.

bold() public méthode

Returns a bold version of $text.
public bold ( string $text ) : string
$text string The text to bold.
Résultat string The bolded text.

clearScreen() public méthode

Clears the entire screen, if possible.
public clearScreen ( )

fatal() public méthode

Displays a fatal error message.
public fatal ( mixed $error )
$error mixed The error text to display, an exception or an object with a getMessage() method.

green() public méthode

Returns a green version of $text.
public green ( string $text ) : string
$text string The text to print in green.
Résultat string The green text.

indent() public méthode

Returns the indented string.
public indent ( string $text ) : string
$text string The text to indent.
Résultat string The indented text.

init() public static méthode

CLI scripts shouldn't timeout, so try to set the time limit to none. Also initialize a few variables in $_SERVER that aren't present from the CLI.
public static init ( ) : Horde_Cli
Résultat Horde_Cli A Horde_Cli instance.

message() public méthode

Displays a message.
public message ( $message, string $type = 'cli.message' )
$type string The type of message: 'cli.error', 'cli.warning', 'cli.success', or 'cli.message'.

passwordPrompt() public méthode

Requires a bash shell or Windows and won't work with safe_mode settings (uses shell_exec). From: http://www.sitepoint.com/blogs/2009/05/01/interactive-cli-password-prompt-in-php/
public passwordPrompt ( string $prompt ) : string
$prompt string The message to display when prompting the user.
Résultat string The user's response to the prompt.

prompt() public méthode

Prompts for a user response.
public prompt ( string $prompt, array $choices = null, string $default = null ) : mixed
$prompt string The message to display when prompting the user.
$choices array The choices available to the user or null for a text input.
$default string The default value if no value specified.
Résultat mixed The user's response to the prompt.

readStdin() public méthode

Reads everything that is sent through standard input and returns it as a single string.
public readStdin ( ) : string
Résultat string The contents of the standard input.

red() public méthode

Returns a red version of $text.
public red ( string $text ) : string
$text string The text to print in red.
Résultat string The red text.

runningFromCLI() public static méthode

Make sure we're being called from the command line, and not via the web.
public static runningFromCLI ( ) : boolean
Résultat boolean True if we are, false otherwise.

shutdown() public méthode

Destroys any session on script end.
public shutdown ( )

writeln() public méthode

Prints $text on a single line.
public writeln ( string $text = '', boolean $pre = false )
$text string The text to print.
$pre boolean If true the linebreak is printed before the text instead of after it.

yellow() public méthode

Returns a yellow version of $text.
public yellow ( string $text ) : string
$text string The text to print in yellow.
Résultat string The yellow text.

Property Details

$_blue_end protected_oe property

protected $_blue_end

$_blue_start protected_oe property

protected $_blue_start

$_bold_end protected_oe property

The string to mark the end of bold text.
protected string $_bold_end
Résultat string

$_bold_start protected_oe property

The string to mark the beginning of bold text.
protected string $_bold_start
Résultat string

$_clearscreen protected_oe property

The string to use for clearing the screen.
protected string $_clearscreen
Résultat string

$_console protected_oe property

Are we running on a console?
protected bool $_console
Résultat boolean

$_green_end protected_oe property

protected $_green_end

$_green_start protected_oe property

protected $_green_start

$_indent protected_oe property

The indent string to use.
protected string $_indent
Résultat string

$_newline protected_oe property

The newline string to use.
protected string $_newline
Résultat string

$_red_end protected_oe property

The strings to mark the end of coloured text.
protected string $_red_end
Résultat string

$_red_start protected_oe property

The strings to mark the beginning of coloured text.
protected string $_red_start
Résultat string

$_terminalBackgrounds protected_oe property

Terminal background color codes. Not used yet.
protected array $_terminalBackgrounds
Résultat array

$_terminalForegrounds protected_oe property

Terminal foreground color codes. Not used yet.
protected array $_terminalForegrounds
Résultat array

$_yellow_end protected_oe property

protected $_yellow_end

$_yellow_start protected_oe property

protected $_yellow_start