diff options
| author | Stig Bakken <ssb@php.net> | 2002-06-02 13:07:19 +0000 |
|---|---|---|
| committer | Stig Bakken <ssb@php.net> | 2002-06-02 13:07:19 +0000 |
| commit | f111dff665fb5501065a67928d1b79e9ad8e89a8 (patch) | |
| tree | 43bfb294046c37fdd3aff537f7a2a9f119667322 /pear/PEAR/Command/Remote.php | |
| parent | b341789bb86a2b3b5acea3253a15ab4efdaf04e2 (diff) | |
| download | php-git-f111dff665fb5501065a67928d1b79e9ad8e89a8.tar.gz | |
* merge NEW_UI_API branch
Diffstat (limited to 'pear/PEAR/Command/Remote.php')
| -rw-r--r-- | pear/PEAR/Command/Remote.php | 170 |
1 files changed, 149 insertions, 21 deletions
diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index 55f2c354b6..2550236be5 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -22,6 +22,7 @@ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Common.php'; require_once 'PEAR/Remote.php'; +require_once 'PEAR/Registry.php'; class PEAR_Command_Remote extends PEAR_Command_Common { @@ -54,6 +55,24 @@ a newer version is available with the same release state (stable etc.).' Lists the packages available on the configured server along with the latest stable release of each package.', ), + 'search' => array( + 'summary' => 'Search Packagesdatabase', + 'function' => 'doSearch', + 'shortcut' => 'sp', + 'options' => array(), + 'doc' => ' +Lists all packages which match the search paramteres (first param +is package name, second package info)', + ), + 'list-all' => array( + 'summary' => 'List All Packages', + 'function' => 'doListAll', + 'shortcut' => 'la', + 'options' => array(), + 'doc' => ' +Lists the packages available on the configured server along with the +latest stable release of each package.', + ), 'download' => array( 'summary' => 'Download Package', 'function' => 'doDownload', @@ -86,10 +105,36 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', // }}} - // {{{ info-remote + // {{{ remote-info - function doInfoRemote($command, $options, $params) + function doRemoteInfo($command, $options, $params) { +/* + return false; // coming soon + + var_dump($params[0]); + $r = new PEAR_Remote($this->config); + $info = $r->call('package.info', $params[0]); + if (PEAR::isError($info)) { + return $this->raiseError($info); + } + + var_dump($info); +*/ + $r = new PEAR_Remote($this->config); + $available = $r->call('package.listAll', true); + if (PEAR::isError($available)) { + return $this->raiseError($available); + } + $info = $available[$params[0]]; + $info["name"] = $params[0]; + + $reg = new PEAR_Registry($this->config->get('php_dir')); + $installed = $reg->packageInfo($info['name']); + $info['installed'] = $installed['version']; + + $this->ui->outputData($info, $command); + return false; // coming soon } @@ -104,21 +149,103 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', return $this->raiseError($available); } $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Available packages:', - 'border' => true)); + $data = array( + 'caption' => 'Available packages:', + 'border' => true, + 'headline' => array('Package', 'Version'), + ); foreach ($available as $name => $info) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version'), - array('bold' => true)); - } - $this->ui->tableRow(array($name, $info['stable'])); + $data['data'][] = array($name, $info['stable']); + } + if (count($available)==0) { + $data = '(no packages installed yet)'; } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); + $this->ui->outputData($data, $command); + return true; + } + + // }}} + // {{{ list-all + + function doListAll($command, $options, $params) + { + $r = new PEAR_Remote($this->config); + $reg = new PEAR_Registry($this->config->get('php_dir')); + $available = $r->call('package.listAll', true); + if (PEAR::isError($available)) { + return $this->raiseError($available); + } + $data = array( + 'caption' => 'All packages:', + 'border' => true, + 'headline' => array('Package', 'Latest', 'Local'), + ); + + foreach ($available as $name => $info) { + $installed = $reg->packageInfo($name); + $desc = $info['summary']; + if (isset($params[$name])) + $desc .= "\n\n".$info['description']; + + $data['data'][$info['category']][] = array( + $name, + $info['stable'], + $installed['version'], + $desc, + ); + } + $this->ui->outputData($data, $command); + return true; + } + + // }}} + // {{{ search + + function doSearch($command, $options, $params) + { + if ((!isset($params[0]) || empty($params[0])) + && (!isset($params[1]) || empty($params[1]))) + { + return $this->raiseError('no valid search string suppliedy<'); + }; + + $r = new PEAR_Remote($this->config); + $reg = new PEAR_Registry($this->config->get('php_dir')); + $available = $r->call('package.listAll', true); + if (PEAR::isError($available)) { + return $this->raiseError($available); + } + $data = array( + 'caption' => 'Matched packages:', + 'border' => true, + 'headline' => array('Package', 'Latest', 'Local'), + ); + + foreach ($available as $name => $info) { + $found = (!empty($params[0]) && stristr($name, $params[0]) !== false); + if (!$found && !(isset($params[1]) && !empty($params[1]) + && (stristr($info['summary'], $params[1]) !== false + || stristr($info['description'], $params[1]) !== false))) + { + continue; + }; + + $installed = $reg->packageInfo($name); + $desc = $info['summary']; + if (isset($params[$name])) + $desc .= "\n\n".$info['description']; + + $data['data'][$info['category']][] = array( + $name, + $info['stable'], + $installed['version'], + $desc, + ); } - $this->ui->endTable(); + if (!isset($data['data'])) { + return $this->raiseError('no packages found'); + }; + $this->ui->outputData($data, $command); return true; } @@ -144,7 +271,7 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', return $this->raiseError($saved); } $fname = basename($saved); - $this->ui->displayLine("File $fname downloaded ($this->bytes_downloaded bytes)"); + $this->ui->outputData("File $fname downloaded ($this->bytes_downloaded bytes)", $command); return true; } @@ -180,10 +307,11 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', } $reg = new PEAR_Registry($this->config->get('php_dir')); $inst = array_flip($reg->listPackages()); - $this->ui->startTable(array('caption' => $caption, - 'border' => 1)); - $this->ui->tableRow(array('Package', 'Version', 'Size'), - array('bold' => true)); + $data = array( + 'caption' => $caption, + 'border' => 1, + 'headline' => array('Package', 'Version', 'Size'), + ); foreach ($latest as $package => $info) { if (!isset($inst[$package])) { // skip packages we don't have installed @@ -204,9 +332,9 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', } else { $fs = " -"; // XXX center instead } - $this->ui->tableRow(array($package, $version, $fs)); + $data['data'][] = array($package, $version, $fs); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } |
