Overview

Packages

  • Cli

Classes

  • Horde_Cli
  • Horde_Cli_Translation
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Cli

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

Copyright 2003-2012 Horde LLC (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Package: Cli
Author: Chuck Hagenbuch chuck@horde.org
Author: Jan Schneider jan@horde.org
Located at Horde/Cli.php
Methods summary
public
# __construct( )

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

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

The constructor must not be called after init().

public
# writeln( string $text = '', boolean $pre = false )

Prints $text on a single line.

Prints $text on a single line.

Parameters

$text
The text to print.
$pre
<p>If true the linebreak is printed before the text instead of after it.</p>
public
# clearScreen( )

Clears the entire screen, if possible.

Clears the entire screen, if possible.

public string
# indent( string $text )

Returns the indented string.

Returns the indented string.

Parameters

$text
The text to indent.

Returns

string
The indented text.
public string
# bold( string $text )

Returns a bold version of $text.

Returns a bold version of $text.

Parameters

$text
The text to bold.

Returns

string
The bolded text.
public string
# red( string $text )

Returns a red version of $text.

Returns a red version of $text.

Parameters

$text
The text to print in red.

Returns

string
The red text.
public string
# green( string $text )

Returns a green version of $text.

Returns a green version of $text.

Parameters

$text
The text to print in green.

Returns

string
The green text.
public string
# blue( string $text )

Returns a blue version of $text.

Returns a blue version of $text.

Parameters

$text
The text to print in blue.

Returns

string
The blue text.
public string
# yellow( string $text )

Returns a yellow version of $text.

Returns a yellow version of $text.

Parameters

$text
The text to print in yellow.

Returns

string
The yellow text.
public
# message( string $message, string $type = 'cli.message' )

Displays a message.

Displays a message.

Parameters

$message
$event The message string.
$type
<p>The type of message: 'cli.error', 'cli.warning', 'cli.success', or 'cli.message'.</p>
public
# fatal( mixed $error )

Displays a fatal error message.

Displays a fatal error message.

Parameters

$error
<p>The error text to display, an exception or an object with a getMessage() method.</p>
public mixed
# prompt( string $prompt, array $choices = null, string $default = null )

Prompts for a user response.

Prompts for a user response.

Parameters

$prompt
The message to display when prompting the user.
$choices
<p>The choices available to the user or null for a text input.</p>
$default
The default value if no value specified.

Returns

mixed
The user's response to the prompt.
public string
# passwordPrompt( string $prompt )

Interactively prompts for input without echoing to the terminal. Requires a bash shell or Windows and won't work with safe_mode settings (uses shell_exec).

Interactively prompts for input without echoing to the terminal. Requires a bash shell or Windows and won't work with safe_mode settings (uses shell_exec).

From: http://www.sitepoint.com/blogs/2009/05/01/interactive-cli-password-prompt-in-php/

Parameters

$prompt
The message to display when prompting the user.

Returns

string
The user's response to the prompt.
public string
# readStdin( )

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

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

Returns

string
The contents of the standard input.
public static Horde_Cli
# init( )

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.

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.

Returns

Horde_Cli
A Horde_Cli instance.
public static boolean
# runningFromCLI( )

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

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

Returns

boolean
True if we are, false otherwise.
public
# shutdown( )

Destroys any session on script end.

Destroys any session on script end.

API documentation generated by ApiGen