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

59
cli.php
View File

@@ -63,6 +63,14 @@ class cli
foreach ($files as $file)
$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")
{
// Lists the classes available in controllers and models if expert mode
@@ -75,7 +83,8 @@ class cli
}
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
if (!isset ($argv[1]))
@@ -109,34 +118,40 @@ class cli
// Look at methods
$methods = $refclass->getMethods();
echo "List of methods available in the class '$class' :\n";
if ($argv[0] !== "-listmethodsonly")
echo "List of methods available in the class '$class' :\n";
foreach ($methods as $key=>$method)
{
if ($method->name === "__construct")
continue;
if ($key > 0)
if ($key > 0 && $argv[0] !== "-listmethodsonly")
echo "\n";
echo " ".$method->name.$constParams;
$r = new ReflectionMethod ($class, $method->name);
$params = $r->getParameters();
foreach ($params as $param)
if ($argv[0] !== "-listmethodsonly")
echo " ";
echo $method->name.$constParams;
if ($argv[0] !== "-listmethodsonly")
{
echo " ";
if ($param->isOptional())
echo "[";
else
echo " <";
echo $param->name;
if ($param->isOptional())
echo "]";
else
echo ">";
}
$r = new ReflectionMethod ($class, $method->name);
$params = $r->getParameters();
foreach ($params as $param)
{
echo " ";
if ($param->isOptional())
echo "[";
else
echo " <";
echo $param->name;
if ($param->isOptional())
echo "]";
else
echo ">";
}
if ($argv[0] === "-listmethodsdetails")
{
echo "\n";
echo trim (substr ($method->getDocComment(), 3, -2));
if ($argv[0] === "-listmethodsdetails")
{
echo "\n";
echo trim (substr ($method->getDocComment(), 3, -2));
}
}
echo "\n";
}