eZPublish  4.4
eZCLI Class Reference

CLI handling. More...

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. More...
 
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->setUseStyles( true ); // enable colors
$cli->output( "This is a text string" );

Member Function Documentation

eZCLI::emptyStyles ( )
Returns
a hash with empty styles.
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.

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.

Referenced by getOptions().

eZCLI::eZCLI ( )

Initializes object and detects if the CLI is used.

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
eZCLI::gotoColumn (   $column)
Returns
an ANSI sequence which will tell the console go to the specified column.
static eZCLI::hasInstance ( )
static
Returns
true if instance of eZCLI already exists otherwise false.
eZCLI::isLoud ( )
Returns
true if output is allowed.
See Also
isQuiet
eZCLI::isQuiet ( )
Returns
true if output is not allowed.
See Also
isLoud

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

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

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.

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.

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

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

static eZCLI::restorePosition ( )
static
Returns
an ANSI sequence which will restore the current position.
eZCLI::setIsQuiet (   $isQuiet)

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

See Also
isQuiet, isLoud
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.
static eZCLI::storePosition ( )
static
Returns
an ANSI sequence which will store the current position.
eZCLI::style (   $name)
Returns
the style for the name $name. The style is taken from the current interface type.

Referenced by stylize().

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

Referenced by error(), and warning().

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

Referenced by style().

eZCLI::terminalStyles ( )
Returns
a hash with all terminal styles.
eZCLI::useStyles ( )
Returns
true if styles are enabled.
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.

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

Referenced by style().

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

Member Data Documentation

const eZCLI::TERMINAL_ENDOFLINE_STRING = "\n"

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