]> granicus.if.org Git - php/commitdiff
* moved get{Help,Commands,Options} here
authorStig Bakken <ssb@php.net>
Tue, 14 May 2002 01:48:20 +0000 (01:48 +0000)
committerStig Bakken <ssb@php.net>
Tue, 14 May 2002 01:48:20 +0000 (01:48 +0000)
pear/PEAR/Command/Common.php

index 471930fa67ae332aa7657c8dc783d15cebbbcff4..dc308c6896b56141a4983ef6f222eb7a3fc11650 100644 (file)
@@ -55,11 +55,28 @@ class PEAR_Command_Common extends PEAR
 
     // }}}
 
-    // {{{ getHelp()
+    // {{{ getCommands()
 
-    function getHelp($command)
+    /**
+     * Return a list of all the commands defined by this class.
+     * @return array list of commands
+     * @access public
+     */
+    function getCommands()
+    {
+        $ret = array();
+        foreach (array_keys($this->commands) as $command) {
+            $ret[$command] = $this->commands[$command]['summary'];
+        }
+        return $ret;
+    }
+
+    // }}}
+    // {{{ getOptions()
+
+    function getOptions($command)
     {
-        return array(null, 'No help avaible yet');
+        return @$this->commands[$command]['options'];
     }
 
     // }}}
@@ -93,6 +110,15 @@ class PEAR_Command_Common extends PEAR
         }
     }
 
+    // }}}
+    // {{{ getHelp()
+
+    function getHelp($command)
+    {
+        $help = preg_replace('/{config\s+([^\}]+)}/e', "\$config->get('\1')", @$this->commands[$command]['doc']);
+        return $help;
+    }
+
     // }}}
     // {{{ run()