PHP Class Phrozn\Runner\CommandLine\Callback\Base

Author: Victor Farazdagi
Inheritance: implements Phrozn\Runner\CommandLine\Callback
Show file Open project: farazdagi/phrozn

Public Methods

Method Description
getConfig ( ) : array Get command config array
getOutputter ( ) : Console_CommandLine_Outputter Get CLI outputter
getParseResult ( ) : Console_CommandLine_Result Get parsed result object
out ( string $str ) : Phrozn\Runner\CommandLine\Callback Output string to stdout (flushes output). Wrapper around Outputter
readLine ( ) : string Read-line either from STDIN or mock unit test data
setConfig ( array $config ) : Phrozn\Runner\CommandLine\Callback Set config data for a given callback
setOutputter ( $out ) : Phrozn\Runner\CommandLine\Callback Set CLI outputter
setParseResult ( Console_CommandLine_Result $result ) : Phrozn\Runner\CommandLine\Callback Result object of CLI input parsing
setUnitTestData ( $data ) : Phrozn\Runner\CommandLine\Callback Since Unit Testing readline can be tricky, confirm answer is exposed to unit test via this method. Simply pass the string you want to be used in place of readline() result.

Protected Methods

Method Description
combine ( string $file, boolean $verbose = false ) : string Combine command documentation
getFooter ( ) : string Phrozn CLI footer
getHeader ( ) : string Phrozn CLI header
getPathArgument ( string $name, boolean $realpath = true, Console_CommandLine_Result $command = null ) : string Extract path argument or fallback to cwd
isAbsolute ( string $path ) : boolean See whether given path is absolute or relative
pad ( $str )
pre ( array $arr ) : string Prepend all lines in array with intendation

Private Methods

Method Description
getCommandMeta ( )
getRealCommandName ( string $file ) : string Search if an alias exists for this command
useAnsiColors ( )

Method Details

combine() protected method

Combine command documentation
protected combine ( string $file, boolean $verbose = false ) : string
$file string Command file to combine
$verbose boolean Whether to provide full documentation or just summary
return string

getConfig() public method

Get command config array
public getConfig ( ) : array
return array

getFooter() protected method

Phrozn CLI footer
protected getFooter ( ) : string
return string

getHeader() protected method

Phrozn CLI header
protected getHeader ( ) : string
return string

getOutputter() public method

Get CLI outputter
public getOutputter ( ) : Console_CommandLine_Outputter
return Console_CommandLine_Outputter CLI outputter instance

getParseResult() public method

Get parsed result object
public getParseResult ( ) : Console_CommandLine_Result
return Console_CommandLine_Result

getPathArgument() protected method

Extract path argument or fallback to cwd
protected getPathArgument ( string $name, boolean $realpath = true, Console_CommandLine_Result $command = null ) : string
$name string Name of the path argument
$realpath boolean Whether to apply realpath() to path
$command Console_CommandLine_Result Command line result to use
return string

isAbsolute() protected method

See whether given path is absolute or relative
protected isAbsolute ( string $path ) : boolean
$path string Path to check
return boolean

out() public method

Output string to stdout (flushes output). Wrapper around Outputter
public out ( string $str ) : Phrozn\Runner\CommandLine\Callback
$str string String to output
return Phrozn\Runner\CommandLine\Callback

pad() protected method

protected pad ( $str )

pre() protected method

Prepend all lines in array with intendation
protected pre ( array $arr ) : string
$arr array Array to combine
return string

readLine() public method

Read-line either from STDIN or mock unit test data
public readLine ( ) : string
return string

setConfig() public method

Set config data for a given callback
public setConfig ( array $config ) : Phrozn\Runner\CommandLine\Callback
$config array Config array
return Phrozn\Runner\CommandLine\Callback

setOutputter() public method

Set CLI outputter
public setOutputter ( $out ) : Phrozn\Runner\CommandLine\Callback
return Phrozn\Runner\CommandLine\Callback

setParseResult() public method

Result object of CLI input parsing
public setParseResult ( Console_CommandLine_Result $result ) : Phrozn\Runner\CommandLine\Callback
$result Console_CommandLine_Result Parser's result
return Phrozn\Runner\CommandLine\Callback

setUnitTestData() public method

Since Unit Testing readline can be tricky, confirm answer is exposed to unit test via this method. Simply pass the string you want to be used in place of readline() result.
public setUnitTestData ( $data ) : Phrozn\Runner\CommandLine\Callback
return Phrozn\Runner\CommandLine\Callback