eZ Publish  [4.2]
eZCLI Class Reference

CLI handling. More...

List of all members.

Public Member Functions

 emptyStyles ()
 endlineString ()
 error ($string=false, $addEOL=true)
 eZCLI ()
 getOptions ($config, $argumentConfig, $arguments=false)
 gotoColumn ($column)
 isLoud ()
 isQuiet ()
 isWebOutput ()
 notice ($string=false, $addEOL=true)
 output ($string=false, $addEOL=true)
 setIsQuiet ($isQuiet)
 setUseStyles ($useStyles)
 style ($name)
 stylize ($styleName, $text)
 terminalStyle ($name)
 terminalStyles ()
 useStyles ()
 warning ($string=false, $addEOL=true)
 webStyle ($name)
 webStyles ()

Static Public Member Functions

static hasInstance ()
static instance ()
 Returns a shared instance of the eZCLI class.
static parseOptionString ($configString, &$optionConfig)
static restorePosition ()
static storePosition ()

Public Attributes

const TERMINAL_ENDOFLINE_STRING = "\n"

Detailed Description

CLI handling.

Provides functionality to work with the CLI (Command Line Interface). The CLI can be run from either a terminal (shell) or a web interface.

A typical usage:

$cli = eZCLI::instance();

$cli->setUseStyles( true ); // enable colors

$cli->output( "This is a text string" );

Definition at line 53 of file ezcli.php.


Member Function Documentation

eZCLI::emptyStyles ( )
Returns:
a hash with empty styles.

Definition at line 282 of file ezcli.php.

eZCLI::endlineString ( )
Returns:
the string used to end lines. This is either the
if CLI is used or
if the script is run in a webinterface.

Definition at line 230 of file ezcli.php.

Referenced by error(), notice(), output(), and warning().

eZCLI::error ( string = false,
addEOL = true 
)

Outputs the string $string to the current interface as an error. If $addEOL is true then the end-of-line string is added.

Definition at line 410 of file ezcli.php.

Referenced by getOptions().

eZCLI::eZCLI ( )

Initializes object and detects if the CLI is used.

Definition at line 60 of file ezcli.php.

Referenced by hasInstance(), and instance().

eZCLI::getOptions ( config,
argumentConfig,
arguments = false 
)

Parses the arguments from array $arguments (or from command line if $arguments == false) according to the options specified by $config and $argumentConfig. Option arguments can be specified using the following formats: -o (option 'o' in short format) -ovalue (option 'o' in short format with value 'value' ) -o value (option 'o' in short format with value 'value' ) --option (option 'option' in long format) --option=value (option 'option' in long format with value 'value' ) Any argument that does not start with a '-' char or follows an option is considered an argument

Parameters:
$configdefinition of options as string or array in internal format. NB: 'quantifier' descriptor of options right now can only be used to specify 1/many values
$argumentconfigdefition of options as string or array in internal format. NB: UNUSED for now
array$arguments
Returns:
array containing a member for every option specified in $config and a member 'arguments' for all non-option arguments. If an option is defined as optional in $config but not present in $arguments, it will be given a null value. If an option is defined as mandatory value in $config but not present in $arguments, the function will return false instead

Definition at line 595 of file ezcli.php.

eZCLI::gotoColumn ( column)
Returns:
an ANSI sequence which will tell the console go to the specified column.

Definition at line 333 of file ezcli.php.

static eZCLI::hasInstance ( ) [static]
Returns:
true if instance of eZCLI already exists otherwise false.

Definition at line 751 of file ezcli.php.

static eZCLI::instance ( ) [static]
eZCLI::isLoud ( )
Returns:
true if output is allowed.
See also:
isQuiet

Definition at line 442 of file ezcli.php.

eZCLI::isQuiet ( )
Returns:
true if output is not allowed.
See also:
isLoud

Definition at line 433 of file ezcli.php.

Referenced by error(), notice(), output(), and warning().

eZCLI::isWebOutput ( )
Returns:
true if the current script is run in a webinterface.

Definition at line 238 of file ezcli.php.

Referenced by style().

eZCLI::notice ( string = false,
addEOL = true 
)

Outputs the string $string to the current interface as a notice. If $addEOL is true then the end-of-line string is added.

Definition at line 383 of file ezcli.php.

eZCLI::output ( string = false,
addEOL = true 
)

Outputs the string $string to the current interface. If $addEOL is true then the end-of-line string is added.

Definition at line 370 of file ezcli.php.

static eZCLI::parseOptionString ( configString,
&$  optionConfig 
) [static]

Parses the string describing command line options into an internal format that is used by getOptions. Format: [o] short-format option, accepts "-o" [o:] short-format option with a value, accepts "-o=value" [o;] short-format option with an optional value, accepts "-o" and "-o=value" [o?] option can be present zero or 1 times (max not enforced yet) [o*] option can be present n times [o+] option can be present 1 or more times (min not enforced yet) [opt] long-format option, accepts "--opt" [o|opt] the option can be given in long or short format [o:|opt:] and [o:+] and similar combinations are also valid weird api: $optionConfig is modified and returned as well

Parameters:
$configStringstring
$optionConfigarray - if it is not empty, parsed options are added to it
Returns:
array members: 'list', 'long', 'short', with 'list' containing both long and short members

Definition at line 465 of file ezcli.php.

Referenced by getOptions(), and eZScript\getOptions().

static eZCLI::restorePosition ( ) [static]
Returns:
an ANSI sequence which will restore the current position.

Definition at line 325 of file ezcli.php.

eZCLI::setIsQuiet ( isQuiet)

Sets whether the output(), notice(), warning() and error() methods should print out anything.

See also:
isQuiet, isLoud

Definition at line 424 of file ezcli.php.

eZCLI::setUseStyles ( useStyles)

Controls whether styles are to be used or not. If disabled empty strings are returned when asking for styles.

Note:
This only controls the style() function.

Definition at line 350 of file ezcli.php.

static eZCLI::storePosition ( ) [static]
Returns:
an ANSI sequence which will store the current position.

Definition at line 316 of file ezcli.php.

eZCLI::style ( name)
Returns:
the style for the name $name. The style is taken from the current interface type.

Definition at line 290 of file ezcli.php.

Referenced by stylize().

eZCLI::stylize ( styleName,
text 
)
Returns:
the text $text wrapped in the style $styleName.

Definition at line 305 of file ezcli.php.

Referenced by error(), and warning().

eZCLI::terminalStyle ( name)
Returns:
the style for the name $name. The style is specific for terminals.

Definition at line 246 of file ezcli.php.

Referenced by style().

eZCLI::terminalStyles ( )
Returns:
a hash with all terminal styles.

Definition at line 266 of file ezcli.php.

eZCLI::useStyles ( )
Returns:
true if styles are enabled.

Definition at line 361 of file ezcli.php.

eZCLI::warning ( string = false,
addEOL = true 
)

Outputs the string $string to the current interface as an warning. If $addEOL is true then the end-of-line string is added.

Definition at line 396 of file ezcli.php.

eZCLI::webStyle ( name)
Returns:
the style for the name $name. The style is specific for web.

Definition at line 258 of file ezcli.php.

Referenced by style().

eZCLI::webStyles ( )
Returns:
a hash with all web styles.

Definition at line 274 of file ezcli.php.


Member Data Documentation

Definition at line 55 of file ezcli.php.

Referenced by eZCLI().


The documentation for this class was generated from the following file: