PHP Класс 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.
Автор: Chuck Hagenbuch ([email protected])
Автор: Jan Schneider ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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

blue() публичный Метод

Returns a blue version of $text.
public blue ( string $text ) : string
$text string The text to print in blue.
Результат string The blue text.

bold() публичный Метод

Returns a bold version of $text.
public bold ( string $text ) : string
$text string The text to bold.
Результат string The bolded text.

clearScreen() публичный Метод

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

fatal() публичный Метод

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() публичный Метод

Returns a green version of $text.
public green ( string $text ) : string
$text string The text to print in green.
Результат string The green text.

indent() публичный Метод

Returns the indented string.
public indent ( string $text ) : string
$text string The text to indent.
Результат string The indented text.

init() публичный статический Метод

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
Результат Horde_Cli A Horde_Cli instance.

message() публичный Метод

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() публичный Метод

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.
Результат string The user's response to the prompt.

prompt() публичный Метод

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.
Результат mixed The user's response to the prompt.

readStdin() публичный Метод

Reads everything that is sent through standard input and returns it as a single string.
public readStdin ( ) : string
Результат string The contents of the standard input.

red() публичный Метод

Returns a red version of $text.
public red ( string $text ) : string
$text string The text to print in red.
Результат string The red text.

runningFromCLI() публичный статический Метод

Make sure we're being called from the command line, and not via the web.
public static runningFromCLI ( ) : boolean
Результат boolean True if we are, false otherwise.

shutdown() публичный Метод

Destroys any session on script end.
public shutdown ( )

writeln() публичный Метод

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() публичный Метод

Returns a yellow version of $text.
public yellow ( string $text ) : string
$text string The text to print in yellow.
Результат string The yellow text.

Описание свойств

$_blue_end защищенное свойство

protected $_blue_end

$_blue_start защищенное свойство

protected $_blue_start

$_bold_end защищенное свойство

The string to mark the end of bold text.
protected string $_bold_end
Результат string

$_bold_start защищенное свойство

The string to mark the beginning of bold text.
protected string $_bold_start
Результат string

$_clearscreen защищенное свойство

The string to use for clearing the screen.
protected string $_clearscreen
Результат string

$_console защищенное свойство

Are we running on a console?
protected bool $_console
Результат boolean

$_green_end защищенное свойство

protected $_green_end

$_green_start защищенное свойство

protected $_green_start

$_indent защищенное свойство

The indent string to use.
protected string $_indent
Результат string

$_newline защищенное свойство

The newline string to use.
protected string $_newline
Результат string

$_red_end защищенное свойство

The strings to mark the end of coloured text.
protected string $_red_end
Результат string

$_red_start защищенное свойство

The strings to mark the beginning of coloured text.
protected string $_red_start
Результат string

$_terminalBackgrounds защищенное свойство

Terminal background color codes. Not used yet.
protected array $_terminalBackgrounds
Результат array

$_terminalForegrounds защищенное свойство

Terminal foreground color codes. Not used yet.
protected array $_terminalForegrounds
Результат array

$_yellow_end защищенное свойство

protected $_yellow_end

$_yellow_start защищенное свойство

protected $_yellow_start