From a886b63eb3222c0b7b11a3da0758856fec2feb23 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 18 Aug 2014 09:53:04 +0000 Subject: [PATCH] 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 --- cli.php | 59 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/cli.php b/cli.php index dec119b..b3d0073 100644 --- a/cli.php +++ b/cli.php @@ -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"; }