PEAR
[ class tree: PEAR ] [ index: PEAR ] [ all elements ]

Class: PEAR_Command

Source Location: /PEAR-1.6.2/PEAR/Command.php

Class Overview


PEAR command class, a simple factory class for administrative commands.


Author(s):

Version:

  • Release: 1.6.2

Copyright:

  • 1997-2006 The PHP Group

Methods


Inherited Variables

Inherited Methods


Class Details

[line 107]
PEAR command class, a simple factory class for administrative commands.

How to implement command classes:

  • The class must be called PEAR_Command_Nnn, installed in the "PEAR/Common" subdir, with a method called getCommands() that returns an array of the commands implemented by the class (see PEAR/Command/Install.php for an example).
  • The class must implement a run() function that is called with three params:
(string) command name (array) assoc array with options, freely defined by each command, for example: array('force' => true) (array) list of the other parameters

The run() function returns a PEAR_CommandResponse object. Use these methods to get information:

int getStatus() Returns PEAR_COMMAND_(SUCCESS|FAILURE|PARTIAL) *_PARTIAL means that you need to issue at least one more command to complete the operation (used for example for validation steps).

string getMessage() Returns a message for the user. Remember, no HTML or other interface-specific markup.

If something unexpected happens, run() returns a PEAR error.

  • DON'T OUTPUT ANYTHING! Return text for output instead.
  • DON'T USE HTML! The text you return will be used from both Gtk, web and command-line interfaces, so for now, keep everything to plain text.
  • DON'T USE EXIT OR DIE! Always use pear errors. From static classes do PEAR::raiseError(), from other classes do $this->raiseError().



[ Top ]


Method Detail

factory   [line 122]

object the &factory( string $command, &$config, object $config)

Get the right object for executing a command.
  • Return: command object or a PEAR error
  • Access: public

Parameters:

string   $command   —  The name of the command
object   $config   —  Instance of PEAR_Config object
   &$config   — 

[ Top ]

getCommands   [line 312]

array getCommands( )

Get the list of currently supported commands, and what classes implement them.
  • Return: command => implementing class
  • Access: public

[ Top ]

getDescription   [line 382]

string getDescription( string $command)

Get description for a command.
  • Return: command description
  • Access: public

Parameters:

string   $command   —  Name of the command

[ Top ]

getFrontendObject   [line 173]

object|PEAR_Error &getFrontendObject( )

Get instance of frontend object.

[ Top ]

getGetoptArgs   [line 354]

void getGetoptArgs( string $command, &$short_args, &$long_args, string $short_args, array $long_args)

Compiles arguments for getopt.
  • Access: public

Parameters:

string   $command   —  command to get optstring for
string   $short_args   —  (reference) short getopt format
array   $long_args   —  (reference) long getopt format
   &$short_args   — 
   &$long_args   — 

[ Top ]

getHelp   [line 401]

void getHelp( string $command)

Get help for command.
  • Access: public

Parameters:

string   $command   —  Name of the command to return help for

[ Top ]

getObject   [line 149]

void &getObject( $command)


Parameters:

   $command   — 

[ Top ]

getShortcuts   [line 331]

array getShortcuts( )

Get the list of command shortcuts.
  • Return: shortcut => command
  • Access: public

[ Top ]

registerCommands   [line 234]

bool registerCommands( [bool $merge = false], [string $dir = null])

Scan through the Command directory looking for classes and see what commands they implement.
  • Return: TRUE on success, a PEAR error on failure
  • Access: public

Parameters:

bool   $merge   —  (optional) if FALSE (default), the new list of commands should replace the current one. If TRUE, new entries will be merged with old.
string   $dir   —  (optional) where (what directory) to look for classes, defaults to the Command subdirectory of the directory from where this file (__FILE__) is included.

[ Top ]

setFrontendClass   [line 190]

object the &setFrontendClass( string $uiclass)

Load current frontend class.
  • Return: frontend object, or a PEAR error

Parameters:

string   $uiclass   —  Name of class implementing the frontend

[ Top ]

setFrontendType   [line 207]

object the setFrontendType( string $uitype)

Set current frontend.
  • Return: frontend object, or a PEAR error

Parameters:

string   $uitype   —  Name of the frontend type (for example "CLI")

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:09:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.