*/
$GLOBALS['_PEAR_Command_uiclass'] = 'PEAR_CommandUI_CLI';
+/**
+* The options accepted by the commands
+* @var string the options
+*/
+$GLOBALS['_PEAR_Command_commandopts'] = '';
+
/**
* PEAR command class, a simple factory class for administrative
* commands.
if (!$merge) {
$GLOBALS['_PEAR_Command_commandlist'] = array();
}
+ $cmdopts = array();
while ($entry = readdir($dp)) {
if ($entry{0} == '.' || substr($entry, -4) != '.php' ||
$entry == 'Common.php')
$class = "PEAR_Command_".substr($entry, 0, -4);
$file = "$dir/$entry";
include_once $file;
+ // List of commands
$implements = call_user_func(array($class, "getCommands"));
foreach ($implements as $command) {
$GLOBALS['_PEAR_Command_commandlist'][$command] = $class;
}
+ // List of options accepted
+ $cmdopts = array_merge($cmdopts, call_user_func(array($class, "getOptions")));
}
+ $GLOBALS['_PEAR_Command_commandopts'] = implode('', $cmdopts);
return true;
}
}
return $GLOBALS['_PEAR_Command_commandlist'];
}
+
+ function getOptions()
+ {
+ if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
+ PEAR_Command::registerCommands();
+ }
+ return $GLOBALS['_PEAR_Command_commandopts'];
+ }
}
?>
\ No newline at end of file
$this->ui = $ui;
}
+ function getOptions()
+ {
+ return array();
+ }
+
/**
* Return a PEAR_CommandResponse object with parameters
* filled in.
// }}}
// {{{ run()
- function run($command, $params)
+ function run($command, $options, $params)
{
$cf =& $this->config;
$failmsg = '';
// }}}
// {{{ run()
- function run($command, $params)
+ function run($command, $options, $params)
{
$installer =& new PEAR_Installer($this->config->get('php_dir'),
$this->config->get('ext_dir'),
$this->config->get('doc_dir'));
$installer->debug = $this->config->get('verbose');
$failmsg = '';
- $options = array();
+ $opts = array();
switch ($command) {
case 'install':
case 'upgrade': {
if ($command == 'upgrade') {
- $options['upgrade'] = true;
+ $opts['upgrade'] = true;
+ }
+ if (isset($options['f'])) {
+ $opts['force'] = true;
}
// The ['force'] and ['nodeps'] options are still missing
- if ($installer->install($params[0], $options, $this->config)) {
+ if ($installer->install(@$params[0], $opts, $this->config)) {
$this->ui->displayLine("install ok");
} else {
$failmsg = "install failed";
}
// }}}
+
+ function getOptions()
+ {
+ return array('f');
+ }
}
?>
\ No newline at end of file
// }}}
// {{{ run()
- function run($command, $params)
+ function run($command, $options, $params)
{
$reg = new PEAR_Registry(); // XXX Use config here
$installed = $reg->packageInfo();
*
* @access public
*/
- function run($command, $params)
+ function run($command, $options, $params)
{
$cf = $this->config;
$failmsg = '';
*
* @access public
*/
- function run($command, $params)
+ function run($command, $options, $params)
{
$failmsg = '';
switch ($command) {
$size = filesize($file);
$contents = fread($fp, $size);
$version = '0.1';
- if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, &$matches)) {
+ if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) {
$version = $matches[1];
$contents = substr($contents, strlen($matches[0]));
}
fwrite($fp, ("POST /xmlrpc.php HTTP/1.0\r\n$req_headers\r\n$request"));
$response = '';
$line1 = fgets($fp, 2048);
- if (!preg_match('!^HTTP/[0-9\.]+ (\d+) (.*)!', $line1, &$matches)) {
+ if (!preg_match('!^HTTP/[0-9\.]+ (\d+) (.*)!', $line1, $matches)) {
return $this->raiseError("PEAR_Remote: invalid HTTP response from XML-RPC server");
}
switch ($matches[1]) {