Allow to display the controllers and the methods line by line to be parseable

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1722 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-08-18 09:53:04 +00:00
parent 33e87e33de
commit a886b63eb3

21
cli.php
View File

@@ -63,6 +63,14 @@ class cli
foreach ($files as $file) foreach ($files as $file)
$classes[$file] = substr (strstr ($file, "_"), 1, -4); $classes[$file] = substr (strstr ($file, "_"), 1, -4);
if (isset ($argv[0]) && $argv[0] === "-listonly")
{
// Lists the classes available in controllers and models if expert mode
// Don't do any presentation to be parseable (by bash completion by example)
echo implode ("\n", $classes)."\n";
exit;
}
if (isset ($argv[0]) && $argv[0] === "-list") if (isset ($argv[0]) && $argv[0] === "-list")
{ {
// Lists the classes available in controllers and models if expert mode // Lists the classes available in controllers and models if expert mode
@@ -75,7 +83,8 @@ class cli
} }
if (isset ($argv[0]) && $argv[0] === "-listmethods" || if (isset ($argv[0]) && $argv[0] === "-listmethods" ||
isset ($argv[0]) && $argv[0] === "-listmethodsdetails") isset ($argv[0]) && $argv[0] === "-listmethodsdetails" ||
isset ($argv[0]) && $argv[0] === "-listmethodsonly")
{ {
// Lists the methods of a class // Lists the methods of a class
if (!isset ($argv[1])) if (!isset ($argv[1]))
@@ -109,14 +118,19 @@ class cli
// Look at methods // Look at methods
$methods = $refclass->getMethods(); $methods = $refclass->getMethods();
if ($argv[0] !== "-listmethodsonly")
echo "List of methods available in the class '$class' :\n"; echo "List of methods available in the class '$class' :\n";
foreach ($methods as $key=>$method) foreach ($methods as $key=>$method)
{ {
if ($method->name === "__construct") if ($method->name === "__construct")
continue; continue;
if ($key > 0) if ($key > 0 && $argv[0] !== "-listmethodsonly")
echo "\n"; echo "\n";
echo " ".$method->name.$constParams; if ($argv[0] !== "-listmethodsonly")
echo " ";
echo $method->name.$constParams;
if ($argv[0] !== "-listmethodsonly")
{
$r = new ReflectionMethod ($class, $method->name); $r = new ReflectionMethod ($class, $method->name);
$params = $r->getParameters(); $params = $r->getParameters();
foreach ($params as $param) foreach ($params as $param)
@@ -138,6 +152,7 @@ class cli
echo "\n"; echo "\n";
echo trim (substr ($method->getDocComment(), 3, -2)); echo trim (substr ($method->getDocComment(), 3, -2));
} }
}
echo "\n"; echo "\n";
} }
exit; exit;