Class Horde_CLI

Description

Horde_CLI:: API for basic command-line functionality/checks.

$Horde: framework/CLI/CLI.php,v 1.42.6.28 2009/11/13 14:28:40 mrubinsk Exp $

Copyright 2003-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /CLI/CLI.php (line 17)


	
			
Variable Summary
Method Summary
 static void init ()
 static boolean runningFromCLI ()
 Horde_CLI Horde_CLI ()
 void blue (string $text)
 void bold (string $text)
 void clearScreen ()
 void fatal (string $error)
 void green (string $text)
 void indent (string $text)
 void message ( $message, [string $type = 'cli.message'], string $event)
 mixed prompt (string $prompt, [array $choices = null], [string $default = null])
 string readStdin ()
 void red (string $text)
 void &singleton ()
 void writeln ([string $text = ''], [boolean $pre = false])
 void yellow (string $text)
 void _shutdown ()
Variables
mixed $_blue_end = '' (line 75)
mixed $_blue_start = '' (line 67)
string $_bold_end = '' (line 59)

The string to mark the end of bold text.

string $_bold_start = '' (line 52)

The string to mark the beginning of bold text.

string $_clearscreen = '' (line 38)

The string to use for clearing the screen.

boolean $_console (line 24)

Are we running on a console?

mixed $_green_end = '' (line 73)
mixed $_green_start = '' (line 65)
string $_indent (line 45)

The indent string to use.

string $_newline (line 31)

The newline string to use.

mixed $_red_end = '' (line 72)

The strings to mark the end of coloured text.

mixed $_red_start = '' (line 64)

The strings to mark the beginning of coloured text.

array $_terminalBackgrounds = array(
'normal' => "\x1B[0m",
'black' => "\x1B[0m",
'red' => "\x1B[41m",
'green' => "\x1B[42m",
'brown' => "\x1B[43m",
'blue' => "\x1B[44m",
'magenta' => "\x1B[45m",
'cyan' => "\x1B[46m",
'lightgray' => "\x1B[47m",
)
(line 106)

Terminal background color codes. Not used yet.

array $_terminalForegrounds = array(
'normal' => "\x1B[0m",
'black' => "\x1B[0m",
'bold' => "\x1b[1m",
'red' => "\x1B[31m",
'green' => "\x1B[32m",
'brown' => "\x1B[33m",
'blue' => "\x1B[34m",
'magenta' => "\x1B[35m",
'cyan' => "\x1B[36m",
'lightgray' => "\x1B[37m",
'white' => "\x1B[1m\x1B[37m",
'darkgray' => "\x1B[1m\x1B[0m",
'lightred' => "\x1B[1m\x1B[31m",
'lightgreen' => "\x1B[1m\x1B[32m",
'yellow' => "\x1B[1m\x1B[33m",
'lightblue' => "\x1B[1m\x1B[34m",
'lightmagenta' => "\x1B[1m\x1B[35m",
'lightcyan' => "\x1B[1m\x1B[36m",
)
(line 81)

Terminal foreground color codes. Not used yet.

mixed $_yellow_end = '' (line 74)
mixed $_yellow_start = '' (line 66)
Methods
static init (line 393)

CLI scripts shouldn't timeout, so try to set the time limit to none. Also initialize a few variables in $_SERVER that aren't present from the CLI.

You must not call init() statically before calling the constructor. Either use the singleton() method to retrieve a Horde_CLI object after calling init(), or don't call init() statically.

static void init ()
static runningFromCLI (line 426)

Make sure we're being called from the command line, and not via the web.

  • return: True if we are, false otherwise.
static boolean runningFromCLI ()
Constructor Horde_CLI (line 138)

Detect the current environment (web server or console) and sets internal values accordingly.

The constructor must not be called after init(). Either use the singleton() method to retrieve a Horde_CLI object, or don't call init() statically.

Horde_CLI Horde_CLI ()
blue (line 251)

Returns a blue version of $text.

void blue (string $text)
  • string $text: The text to print in blue.
bold (line 221)

Returns a bold version of $text.

void bold (string $text)
  • string $text: The text to bold.
clearScreen (line 201)

Clears the entire screen, if possible.

  • since: Horde 3.2
void clearScreen ()
fatal (line 304)

Displays a fatal error message.

void fatal (string $error)
  • string $error: The error text to display.
green (line 241)

Returns a green version of $text.

void green (string $text)
  • string $text: The text to print in green.
indent (line 211)

Returns the indented string.

void indent (string $text)
  • string $text: The text to indent.
message (line 273)

Displays a message.

void message ( $message, [string $type = 'cli.message'], string $event)
  • string $event: The message string.
  • string $type: The type of message: 'cli.error', 'cli.warning', 'cli.success', or 'cli.message'.
  • $message
prompt (line 327)

Prompts for a user response.

  • return: The user's response to the prompt.
  • todo: Horde 4: switch $choices and $default
mixed prompt (string $prompt, [array $choices = null], [string $default = null])
  • string $prompt: The message to display when prompting the user.
  • array $choices: The choices available to the user or null for a text input.
  • string $default: The default value if no value specified.
readStdin (line 373)

Reads everything that is sent through standard input and returns it as a single string.

  • return: The contents of the standard input.
string readStdin ()
red (line 231)

Returns a red version of $text.

void red (string $text)
  • string $text: The text to print in red.
singleton (line 121)

Returns a single instance of the Horde_CLI class.

void &singleton ()
writeln (line 187)

Prints $text on a single line.

void writeln ([string $text = ''], [boolean $pre = false])
  • string $text: The text to print.
  • boolean $pre: If true the linebreak is printed before the text instead of after it.
yellow (line 261)

Returns a yellow version of $text.

void yellow (string $text)
  • string $text: The text to print in yellow.
_shutdown (line 439)

Destroys any session on script end.

void _shutdown ()

Documentation generated on Sun, 30 Jan 2011 05:15:47 +0000 by phpDocumentor 1.4.3