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"; }