PHP 클래스 lithium\console\Command

상속: extends lithium\core\Object
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$help boolean Similar to running li3 help COMMAND.
$plain boolean Only shows only text output without styles.
$request object A Request object.
$response object A Response object.
$silent boolean Only shows error output.

보호된 프로퍼티들

프로퍼티 타입 설명
$_autoConfig array Auto configuration.
$_classes array Dynamic dependencies.

공개 메소드들

메소드 설명
__construct ( array $config = [] ) : void Constructor.
__invoke ( string $action, array $args = [] ) : object Called by the Dispatcher class to invoke an action.
clear ( ) : void Clears the entire screen.
columns ( array $rows, array $options = [] ) : void Writes rows of columns.
error ( string | array $error = null, mixed $options = ['nl' => 1] ) : integer Writes a string to error stream.
header ( string $text, integer $line = null ) : void Writes a header to the output stream. In addition to the actual text, horizontal lines before and afterwards are written. The lines will have the same length as the text. This behavior can be modified by providing the length of lines as a second paramerter.
hr ( integer $length = 80, integer $newlines = 1 ) : integer Adds a horizontal line to output stream.
in ( string $prompt = null, array $options = [] ) : string | boolean Handles input. Will continue to loop until $options['quit'] or result is part of $options['choices'].
nl ( integer $number = 1 ) : string Add newlines ("\n") a given number of times and return them in a single string.
out ( string | array $output = null, mixed $options = ['nl' => 1] ) : integer Writes a string to the output stream.
stop ( integer $status, string | null $message = null ) : void Stop execution, by exiting the script.

보호된 메소드들

메소드 설명
_help ( ) : boolean Invokes the Help command.
_init ( ) : void Command Initializer.
_response ( string $type, string | array $string, mixed $options ) : void Handles the response that is sent to the stream.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'request'` _object|null_ - `'response'` _array_ - `'classes'` _array_
리턴 void

__invoke() 공개 메소드

Called by the Dispatcher class to invoke an action.
또한 보기: lithium\console\Dispatcher
또한 보기: lithium\console\Response
public __invoke ( string $action, array $args = [] ) : object
$action string The name of the method to run.
$args array The arguments from the request.
리턴 object The response object associated with this command.

_help() 보호된 메소드

The invoked Help command will take over request and response objects of the originally invoked command. Thus the response of the Help command becomes the response of the original one.
protected _help ( ) : boolean
리턴 boolean

_init() 보호된 메소드

Populates the $response property with a new instance of the Response class passing it configuration and assigns the values from named parameters of the request (if applicable) to properties of the command.
protected _init ( ) : void
리턴 void

_response() 보호된 메소드

Handles the response that is sent to the stream.
protected _response ( string $type, string | array $string, mixed $options ) : void
$type string The stream either output or error.
$string string | array The message to render.
$options mixed When passed an integer or boolean it is used as the number of of new lines, when passed a string it is interpreted as style to use otherwise when an array following options are available: - `'nl'` _integer|boolean_: number of new lines to add at the end. `false` to disable adding a newline. - `'style'` _string_: the style name to wrap around the output.
리턴 void

clear() 공개 메소드

Clears the entire screen.
public clear ( ) : void
리턴 void

columns() 공개 메소드

This method expects asceding integer values as the keys, which map to the appropriate columns. Currently, there is no special "header" option, but you can define them for your own. Example Usage: $output = array( array('Name', 'Age'), array('----', '---'), ); foreach($users as $user) { $output[] = array($user->name, $user->age); } $this->columns($output); Would render something similar to: Name Age ---- --- Jane Doe 22 Foo Bar 18 This method also calculates the needed space between the columns. All option params given also get passed down to the out() method, which allow custom formatting. Passing something like $this->columns($output, array('style' => 'red) would print the table in red.
또한 보기: lithium\console\Response::styles()
public columns ( array $rows, array $options = [] ) : void
$rows array The rows to print, with each column as an array element.
$options array Optional params: - separator : Different column separator, defaults to `\t` - style : the style name to wrap around the columns output
리턴 void

error() 공개 메소드

Writes a string to error stream.
public error ( string | array $error = null, mixed $options = ['nl' => 1] ) : integer
$error string | array The string or an array of strings to write.
$options mixed When passed an integer or boolean it is used as the number of of new lines, when passed a string it is interpreted as style to use otherwise when an array following options are available: - `'nl'` _integer|boolean_: number of new lines to add at the end. `false` to disable adding a newline. - `'style'` _string_: the style name to wrap around the output.
리턴 integer

header() 공개 메소드

Given the text 'Lithium' this generates following output: ------- Lithium -------
public header ( string $text, integer $line = null ) : void
$text string The heading text.
$line integer The length of the line. Defaults to the length of text.
리턴 void

hr() 공개 메소드

Adds a horizontal line to output stream.
public hr ( integer $length = 80, integer $newlines = 1 ) : integer
$length integer The length of the line, defaults to 80.
$newlines integer How many new lines to print afterwards, defaults to 1.
리턴 integer

in() 공개 메소드

Handles input. Will continue to loop until $options['quit'] or result is part of $options['choices'].
public in ( string $prompt = null, array $options = [] ) : string | boolean
$prompt string
$options array
리턴 string | boolean Returns the result of the input data. If the input is equal to the `quit` option boolean `false` is returned.

nl() 공개 메소드

Add newlines ("\n") a given number of times and return them in a single string.
public nl ( integer $number = 1 ) : string
$number integer The number of new lines to fill into a string.
리턴 string

out() 공개 메소드

Writes a string to the output stream.
public out ( string | array $output = null, mixed $options = ['nl' => 1] ) : integer
$output string | array The string or an array of strings to write.
$options mixed When passed an integer or boolean it is used as the number of of new lines, when passed a string it is interpreted as style to use otherwise when an array following options are available: - `'nl'` _integer|boolean_: number of new lines to add at the end. `false` to disable adding a newline. - `'style'` _string_: the style name to wrap around the output.
리턴 integer

stop() 공개 메소드

Stop execution, by exiting the script.
public stop ( integer $status, string | null $message = null ) : void
$status integer Numeric value that will be used on `exit()`.
$message string | null An optional message that will be written to the stream.
리턴 void

프로퍼티 상세

$_autoConfig 보호되어 있는 프로퍼티

Auto configuration.
protected array $_autoConfig
리턴 array

$_classes 보호되어 있는 프로퍼티

Dynamic dependencies.
protected array $_classes
리턴 array

$help 공개적으로 프로퍼티

Similar to running li3 help COMMAND.
public bool $help
리턴 boolean

$plain 공개적으로 프로퍼티

Only shows only text output without styles.
public bool $plain
리턴 boolean

$request 공개적으로 프로퍼티

A Request object.
또한 보기: lithium\console\Request
public object $request
리턴 object

$response 공개적으로 프로퍼티

A Response object.
또한 보기: lithium\console\Response
public object $response
리턴 object

$silent 공개적으로 프로퍼티

Only shows error output.
public bool $silent
리턴 boolean