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

Class: PEAR_Command

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

Class Overview


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


Author(s):

Version:

  • Release: 1.10.12

Copyright:

  • 1997-2009 The Authors

Methods


Inherited Variables

Inherited Methods


Class Details

[line 100]
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 112]

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 299]

array getCommands( )

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

[ Top ]

getDescription   [line 360]

string getDescription( string $command)

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

Parameters:

string   $command   —  Name of the command

[ Top ]

getFrontendObject   [line 162]

object|PEAR_Error &getFrontendObject( )

Get instance of frontend object.
  • Access: public

[ Top ]

getGetoptArgs   [line 335]

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 376]

void getHelp( string $command)

Get help for command.
  • Access: public

Parameters:

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

[ Top ]

getObject   [line 139]

void &getObject( $command)

  • Access: public

Parameters:

   $command   — 

[ Top ]

getShortcuts   [line 315]

array getShortcuts( )

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

[ Top ]

registerCommands   [line 218]

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 178]

object the &setFrontendClass( string $uiclass)

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

Parameters:

string   $uiclass   —  Name of class implementing the frontend

[ Top ]

setFrontendType   [line 194]

object the setFrontendType( string $uitype)

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

Parameters:

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

[ Top ]


Documentation generated on Sun, 19 Apr 2020 14:22:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.