Class CLI
Class CLI
Your commandline script should inherit from this class and implement the abstract methods.
Abstract
Namespace: splitbrain\phpcli
License: MIT
Author: Andreas Gohr andi@splitbrain.org
Located at src/CLI.php
Methods summary
Namespace: splitbrain\phpcli
License: MIT
Author: Andreas Gohr andi@splitbrain.org
Located at src/CLI.php
public
#
__construct( boolean $autocatch = true )
constructor
constructor
Initialize the arguments, set up helper classes and set up the CLI environment
Parameters
- $autocatch
- should exceptions be catched and handled automatically?
abstract protected
#
setup( splitbrain\phpcli\Options
$options )
Register options and arguments on the given $options object
Register options and arguments on the given $options object
Parameters
- $options
Throws
abstract protected
#
main( splitbrain\phpcli\Options
$options )
Your main program
Your main program
Arguments and options have been parsed when this is run
Parameters
- $options
Throws
public
protected
#
registerDefaultOptions( )
Add the default help, color and log options
Add the default help, color and log options
protected
protected
protected
protected
public
public
public
public
public
public
public
public
public
public
public
public
string
#
interpolate( $message, array $context = array() )
Interpolates context values into the message placeholders.
Interpolates context values into the message placeholders.
Parameters
- $message
- $context
Returns
string
protected
array
$loglevel
PSR-3 compatible loglevels and their prefix, color, output channel
PSR-3 compatible loglevels and their prefix, color, output channel
#
array(
'debug' => array('', Colors::C_RESET, STDOUT),
'info' => array('i ', Colors::C_CYAN, STDOUT),
'notice' => array('☛ ', Colors::C_CYAN, STDOUT),
'success' => array('✓ ', Colors::C_GREEN, STDOUT),
'warning' => array('⚠ ', Colors::C_BROWN, STDERR),
'error' => array('✗ ', Colors::C_RED, STDERR),
'critical' => array('☠ ', Colors::C_LIGHTRED, STDERR),
'alert' => array('✖ ', Colors::C_LIGHTRED, STDERR),
'emergency' => array('✘ ', Colors::C_LIGHTRED, STDERR),
)