From: Tomas V.V.Cox Date: Fri, 7 Jun 2002 15:06:25 +0000 (+0000) Subject: Beautify remote-info X-Git-Tag: php5_5_0~139 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcd6d2b5cda9fc9ef582771b750c93ba09494828;p=php Beautify remote-info --- diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index e34b3c768d..9cb8106e54 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -61,7 +61,7 @@ latest stable release of each package.', 'shortcut' => 'sp', 'options' => array(), 'doc' => ' -Lists all packages which match the search paramteres (first param +Lists all packages which match the search paramteres (first param is package name, second package info)', ), 'list-all' => array( @@ -109,18 +109,9 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', 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); + if (sizeof($params) != 1) { + return $this->raiseError("$command expects one param: the remote package name"); } - - var_dump($info); -*/ $r = new PEAR_Remote($this->config); $available = $r->call('package.listAll', true); if (PEAR::isError($available)) { @@ -131,11 +122,9 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', $reg = new PEAR_Registry($this->config->get('php_dir')); $installed = $reg->packageInfo($info['name']); - $info['installed'] = $installed['version']; - + $info['installed'] = $installed['version'] ? $installed['version'] : '- no -'; + $this->ui->outputData($info, $command); - - return true; // coming soon } // }}} @@ -180,16 +169,16 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', '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'], + $name, + $info['stable'], $installed['version'], $desc, ); @@ -206,9 +195,9 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', if ((!isset($params[0]) || empty($params[0])) && (!isset($params[1]) || empty($params[1]))) { - return $this->raiseError('no valid search string suppliedy<'); + return $this->raiseError('no valid search string supplied'); }; - + $r = new PEAR_Remote($this->config); $reg = new PEAR_Registry($this->config->get('php_dir')); $available = $r->call('package.listAll', true); @@ -220,24 +209,24 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', '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'], + $name, + $info['stable'], $installed['version'], $desc, ); diff --git a/pear/PEAR/Frontend/CLI.php b/pear/PEAR/Frontend/CLI.php index e9c4cc9eab..9dc16744c9 100644 --- a/pear/PEAR/Frontend/CLI.php +++ b/pear/PEAR/Frontend/CLI.php @@ -398,14 +398,14 @@ class PEAR_Frontend_CLI extends PEAR case 'remote-info': $data = array( 'caption' => 'Package details:', - 'border' => false, + 'border' => true, 'data' => array( - array("Latest", $data['stable']), + array("Latest", $data['stable']), array("Installed", $data['installed']), - array("Package", $data['name']), - array("License", $data['license']), - array("Category", $data['category']), - array("Summary", $data['summary']), + array("Package", $data['name']), + array("License", $data['license']), + array("Category", $data['category']), + array("Summary", $data['summary']), array("Description", $data['description']), ), ); @@ -418,7 +418,7 @@ class PEAR_Frontend_CLI extends PEAR $opts = array(0 => array('wrap' => 25), 1 => array('wrap' => 55) ); - } else { + } elseif ($count == 3) { $opts = array(0 => array('wrap' => 20), 1 => array('wrap' => 20), 2 => array('wrap' => 40)