]> granicus.if.org Git - php/commitdiff
Implemented "pear info <Installed Package>" command
authorTomas V.V.Cox <cox@php.net>
Thu, 6 Jun 2002 07:25:07 +0000 (07:25 +0000)
committerTomas V.V.Cox <cox@php.net>
Thu, 6 Jun 2002 07:25:07 +0000 (07:25 +0000)
# Stig, why I'm sure that you already have implemented this
# command? Have to stop with my LSD therapy

pear/PEAR/Command/Registry.php

index 1196a870c68ad9432c7adbeb0ccbbb3908e05c88..84ba59decfdd8d83d2acf62f0fe60afd0902c498 100644 (file)
@@ -50,6 +50,13 @@ Tests if a package is installed in the system. Will exit(1) if it is not.
                 <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
    <version>    The version to compare with
 '),
+        'info' => array(
+            'summary'  => 'Information of an installed package',
+            'function' => 'doInfo',
+            'shortcut' => 'i',
+            'options'  => array(),
+            'doc'      => '[package] Displays the information of an installed package'
+            )
         );
 
     // }}}
@@ -159,7 +166,7 @@ Tests if a package is installed in the system. Will exit(1) if it is not.
             }
             $this->ui->outputData($data, $command);
 
-            
+
         }
         return true;
     }
@@ -167,7 +174,8 @@ Tests if a package is installed in the system. Will exit(1) if it is not.
     // }}}
     // {{{ doShellTest()
 
-    function doShellTest($command, $options, $params) {
+    function doShellTest($command, $options, $params)
+    {
         $this->pushErrorHandling(PEAR_ERROR_RETURN);
         $reg = &new PEAR_Registry($this->config->get('php_dir'));
         // "pear shell-test Foo"
@@ -194,6 +202,27 @@ Tests if a package is installed in the system. Will exit(1) if it is not.
         }
     }
 
+    // }}}
+    // {{{ doInfo
+
+    function doInfo($command, $options, $params)
+    {
+        // $params[0] The package for showing info
+        if (sizeof($params) != 1) {
+            return $this->raiseError("This command only accepts one param: ".
+                                     "the package you want information");
+        }
+        $package = $params[0];
+        $reg = &new PEAR_Registry($this->config->get('php_dir'));
+        if (!$reg->packageExists($package)) {
+            return $this->raiseError("The package $package is not installed");
+        }
+        $info = $reg->packageInfo($package);
+        include_once 'PEAR/Command/Package.php';
+        $data = &PEAR_Command_Package::_infoForDisplaying($info);
+        $this->ui->outputData($data, $command);
+    }
+
     // }}}
 }