Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZCLI Class Reference

CLI handling. More...

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

## Static Public Member Functions
static | storePosition ()
static | restorePosition ()
static | parseOptionString ( $configString, &$optionConfig)
static | instance ()
static | hasInstance ()

## Public Attributes
| $EndlineString
| $WebOutput
| $TerminalStyles
| $WebStyles
| $EmptyStyles
| $UseStyles
| $IsQuiet
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" );
eZCLI\instance
static instance()
Definition: ezcli.php:717

Definition at line 30 of file ezcli.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZCLI::__construct | ( |  | ) |

Initializes object and detects if the CLI is used.

Definition at line 44 of file ezcli.php.

References TERMINAL_ENDOFLINE_STRING.

## Member Function Documentation

## ◆ emptyStyles()

eZCLI::emptyStyles | ( |  | ) |

Returns
  a hash with empty styles.

Definition at line 266 of file ezcli.php.

References $EmptyStyles.

## ◆ endlineString()

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

References $EndlineString.

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

## ◆ error()

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

References endlineString(), and stylize().

Referenced by getOptions().

## ◆ getOptions()

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

  | $config | definition 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
  | $argumentconfig | defition 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 575 of file ezcli.php.

References error(), and parseOptionString().

## ◆ gotoColumn()

eZCLI::gotoColumn | ( |  | $column | ) |

Returns
  an ANSI sequence which will tell the console go to the specified column.

Definition at line 317 of file ezcli.php.

## ◆ hasInstance()

static eZCLI::hasInstance | ( |  | ) |
| static

Returns
  `true` if instance of eZCLI already exists otherwise `false`.

Definition at line 731 of file ezcli.php.

## ◆ instance()

static eZCLI::instance | ( |  | ) |
| static

Returns a shared instance of the eZCLI class.

Returns
  eZCLI

Definition at line 717 of file ezcli.php.

Referenced by eZExecution\defaultExceptionHandler(), eZCodeMapper\error(), eZFatalError(), eZScript\getOptions(), eZScript\initialize(), eZScript\setIsQuiet(), eZScript\showHelp(), eZScript\shutdown(), eZScript\startup(), eZScript\updateDebugSettings(), and eZCodeMapper\warning().

## ◆ isLoud()

eZCLI::isLoud | ( |  | ) |

Returns
  `true` if output is allowed.

See also
  isQuiet

Definition at line 423 of file ezcli.php.

References $IsQuiet.

## ◆ isQuiet()

eZCLI::isQuiet | ( |  | ) |

Returns
  `true` if output is not allowed.

See also
  isLoud

Definition at line 414 of file ezcli.php.

References $IsQuiet.

Referenced by output().

## ◆ isWebOutput()

eZCLI::isWebOutput | ( |  | ) |

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

Definition at line 222 of file ezcli.php.

References $WebOutput.

Referenced by style().

## ◆ notice()

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

References endlineString().

## ◆ output()

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

References endlineString(), and isQuiet().

## ◆ parseOptionString()

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

  $configString | string
  $optionConfig | array - 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 446 of file ezcli.php.

References eZDebug\writeError().

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

## ◆ restorePosition()

static eZCLI::restorePosition | ( |  | ) |
| static

Returns
  an ANSI sequence which will restore the current position.

Definition at line 309 of file ezcli.php.

## ◆ setIsQuiet()

eZCLI::setIsQuiet | ( |  | $isQuiet | ) |

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

Parameters

  bool | $isQuiet |

See also
  isQuiet, isLoud

Definition at line 405 of file ezcli.php.

## ◆ setUseStyles()

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

## ◆ storePosition()

static eZCLI::storePosition | ( |  | ) |
| static

Returns
  an ANSI sequence which will store the current position.

Definition at line 300 of file ezcli.php.

## ◆ style()

eZCLI::style | ( |  | $name | ) |

Returns
  the style for the name $name. The style is taken from the current interface type.

Definition at line 274 of file ezcli.php.

References isWebOutput(), terminalStyle(), and webStyle().

Referenced by stylize().

## ◆ stylize()

eZCLI::stylize | ( |  | $styleName,
|  |  | $text
| ) |  |

Returns
  the text $text wrapped in the style $styleName.

Definition at line 289 of file ezcli.php.

References style().

Referenced by error(), and warning().

## ◆ terminalStyle()

eZCLI::terminalStyle | ( |  | $name | ) |

Returns
  the style for the name $name. The style is specific for terminals.

Definition at line 230 of file ezcli.php.

Referenced by style().

## ◆ terminalStyles()

eZCLI::terminalStyles | ( |  | ) |

Returns
  a hash with all terminal styles.

Definition at line 250 of file ezcli.php.

References $TerminalStyles.

## ◆ useStyles()

eZCLI::useStyles | ( |  | ) |

Returns
  `true` if styles are enabled.

Definition at line 345 of file ezcli.php.

References $UseStyles.

## ◆ warning()

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

References endlineString(), and stylize().

## ◆ webStyle()

eZCLI::webStyle | ( |  | $name | ) |

Returns
  the style for the name $name. The style is specific for web.

Definition at line 242 of file ezcli.php.

Referenced by style().

## ◆ webStyles()

eZCLI::webStyles | ( |  | ) |

Returns
  a hash with all web styles.

Definition at line 258 of file ezcli.php.

References $WebStyles.

## Member Data Documentation

## ◆ $EmptyStyles

eZCLI::$EmptyStyles

Definition at line 36 of file ezcli.php.

Referenced by emptyStyles().

## ◆ $EndlineString

eZCLI::$EndlineString

Definition at line 32 of file ezcli.php.

Referenced by endlineString().

## ◆ $IsQuiet

eZCLI::$IsQuiet

Definition at line 38 of file ezcli.php.

Referenced by isLoud(), and isQuiet().

## ◆ $TerminalStyles

eZCLI::$TerminalStyles

Definition at line 34 of file ezcli.php.

Referenced by terminalStyles().

## ◆ $UseStyles

eZCLI::$UseStyles

Definition at line 37 of file ezcli.php.

Referenced by useStyles().

## ◆ $WebOutput

eZCLI::$WebOutput

Definition at line 33 of file ezcli.php.

Referenced by isWebOutput().

## ◆ $WebStyles

eZCLI::$WebStyles

Definition at line 35 of file ezcli.php.

Referenced by webStyles().

## ◆ TERMINAL_ENDOFLINE_STRING

const eZCLI::TERMINAL_ENDOFLINE_STRING = "\n"

Definition at line 39 of file ezcli.php.

Referenced by __construct().

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

- ezcli.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.