summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pear/PEAR/Command.php19
-rw-r--r--pear/PEAR/Command/Common.php5
-rw-r--r--pear/PEAR/Command/Config.php2
-rw-r--r--pear/PEAR/Command/Install.php16
-rw-r--r--pear/PEAR/Command/List.php2
-rw-r--r--pear/PEAR/Command/Login.php2
-rw-r--r--pear/PEAR/Command/Package.php2
-rw-r--r--pear/PEAR/Config.php2
-rw-r--r--pear/PEAR/Remote.php2
9 files changed, 42 insertions, 10 deletions
diff --git a/pear/PEAR/Command.php b/pear/PEAR/Command.php
index 46c3d23299..f0f88eaefe 100644
--- a/pear/PEAR/Command.php
+++ b/pear/PEAR/Command.php
@@ -34,6 +34,12 @@ $GLOBALS['_PEAR_Command_commandlist'] = array();
$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.
*
@@ -154,6 +160,7 @@ class PEAR_Command
if (!$merge) {
$GLOBALS['_PEAR_Command_commandlist'] = array();
}
+ $cmdopts = array();
while ($entry = readdir($dp)) {
if ($entry{0} == '.' || substr($entry, -4) != '.php' ||
$entry == 'Common.php')
@@ -163,11 +170,15 @@ class PEAR_Command
$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;
}
@@ -186,6 +197,14 @@ class PEAR_Command
}
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
diff --git a/pear/PEAR/Command/Common.php b/pear/PEAR/Command/Common.php
index 8883b5eb57..0ae02ebddd 100644
--- a/pear/PEAR/Command/Common.php
+++ b/pear/PEAR/Command/Common.php
@@ -49,6 +49,11 @@ class PEAR_Command_Common extends PEAR
$this->ui = $ui;
}
+ function getOptions()
+ {
+ return array();
+ }
+
/**
* Return a PEAR_CommandResponse object with parameters
* filled in.
diff --git a/pear/PEAR/Command/Config.php b/pear/PEAR/Command/Config.php
index 06a331399f..71009bc16c 100644
--- a/pear/PEAR/Command/Config.php
+++ b/pear/PEAR/Command/Config.php
@@ -59,7 +59,7 @@ class PEAR_Command_Config extends PEAR_Command_Common
// }}}
// {{{ run()
- function run($command, $params)
+ function run($command, $options, $params)
{
$cf =& $this->config;
$failmsg = '';
diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php
index a2131ebce3..6cfd8e65cc 100644
--- a/pear/PEAR/Command/Install.php
+++ b/pear/PEAR/Command/Install.php
@@ -60,22 +60,25 @@ class PEAR_Command_Install extends PEAR_Command_Common
// }}}
// {{{ 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";
@@ -101,6 +104,11 @@ class PEAR_Command_Install extends PEAR_Command_Common
}
// }}}
+
+ function getOptions()
+ {
+ return array('f');
+ }
}
?> \ No newline at end of file
diff --git a/pear/PEAR/Command/List.php b/pear/PEAR/Command/List.php
index 489a4bc6d6..7334c1802b 100644
--- a/pear/PEAR/Command/List.php
+++ b/pear/PEAR/Command/List.php
@@ -59,7 +59,7 @@ class PEAR_Command_List extends PEAR_Command_Common
// }}}
// {{{ run()
- function run($command, $params)
+ function run($command, $options, $params)
{
$reg = new PEAR_Registry(); // XXX Use config here
$installed = $reg->packageInfo();
diff --git a/pear/PEAR/Command/Login.php b/pear/PEAR/Command/Login.php
index cd958752fa..44c85c909b 100644
--- a/pear/PEAR/Command/Login.php
+++ b/pear/PEAR/Command/Login.php
@@ -70,7 +70,7 @@ class PEAR_Command_Login extends PEAR_Command_Common
*
* @access public
*/
- function run($command, $params)
+ function run($command, $options, $params)
{
$cf = $this->config;
$failmsg = '';
diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php
index 03b118c5e4..f3f7a27e67 100644
--- a/pear/PEAR/Command/Package.php
+++ b/pear/PEAR/Command/Package.php
@@ -48,7 +48,7 @@ class PEAR_Command_Package extends PEAR_Command_Common
*
* @access public
*/
- function run($command, $params)
+ function run($command, $options, $params)
{
$failmsg = '';
switch ($command) {
diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php
index 75d38a2ddd..68e9fa772e 100644
--- a/pear/PEAR/Config.php
+++ b/pear/PEAR/Config.php
@@ -355,7 +355,7 @@ class PEAR_Config extends PEAR
$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]));
}
diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php
index aba4b24780..3ecbb5f4f5 100644
--- a/pear/PEAR/Remote.php
+++ b/pear/PEAR/Remote.php
@@ -74,7 +74,7 @@ class PEAR_Remote extends PEAR
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]) {