eZ Publish  [trunk]
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)
 Sets whether the output() method should print out anything.
 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 30 of file ezcli.php.


Member Function Documentation

Returns:
a hash with empty styles.

Definition at line 259 of file ezcli.php.

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 207 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 383 of file ezcli.php.

Referenced by getOptions().

Initializes object and detects if the CLI is used.

Definition at line 37 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 568 of file ezcli.php.

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

Definition at line 310 of file ezcli.php.

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

Definition at line 724 of file ezcli.php.

Returns:
true if output is allowed.
See also:
isQuiet

Definition at line 416 of file ezcli.php.

Returns:
true if output is not allowed.
See also:
isLoud

Definition at line 407 of file ezcli.php.

Referenced by output().

Returns:
true if the current script is run in a webinterface.

Definition at line 215 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 360 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 347 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 439 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 302 of file ezcli.php.

eZCLI::setIsQuiet ( isQuiet)

Sets whether the output() method should print out anything.

Parameters:
bool$isQuiet
See also:
isQuiet, isLoud

Definition at line 398 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 327 of file ezcli.php.

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

Definition at line 293 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 267 of file ezcli.php.

Referenced by stylize().

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

Definition at line 282 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 223 of file ezcli.php.

Referenced by style().

Returns:
a hash with all terminal styles.

Definition at line 243 of file ezcli.php.

Returns:
true if styles are enabled.

Definition at line 338 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 371 of file ezcli.php.

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

Definition at line 235 of file ezcli.php.

Referenced by style().

Returns:
a hash with all web styles.

Definition at line 251 of file ezcli.php.


Member Data Documentation

Definition at line 32 of file ezcli.php.

Referenced by eZCLI().


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