Display the call stack in Expert mode of CLI

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1747 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-08-21 09:42:59 +00:00
parent 080d0c2e16
commit 8d7f1549e8

21
cli.php
View File

@@ -13,6 +13,7 @@ class cli
require ("domframework/cli.php");
$cli = new cli;
$cli->run(); */
private $EXPERT = false;
public function __construct ()
{
@@ -49,6 +50,12 @@ class cli
file_put_contents ("php://stderr", sprintf ("%-17s", $severity)." ".
"$errstr [".basename ($errfile) .
":$errline]\n");
if ($this->EXPERT)
{
$e = new Exception;
file_put_contents ("php://stderr",
print_r ($e->getTraceAsString(), TRUE)."\n");
}
}
public function run ()
@@ -83,20 +90,20 @@ class cli
exit;
}
$EXPERT = FALSE;
$this->EXPERT = FALSE;
if (isset ($argv[0]) && $argv[0] === "-expert")
{
$EXPERT = TRUE;
$this->EXPERT = TRUE;
array_shift ($argv);
}
// List the controllers and the models if the expert mode is activated
$files = glob ("controllers/*.php");
if ($EXPERT)
if ($this->EXPERT)
$files = array_merge ($files, glob ("models/*.php"));
if (count ($files) === 0 && $EXPERT === FALSE)
if (count ($files) === 0 && $this->EXPERT === FALSE)
die ("No controllers available in ".getcwd()."\n");
if (count ($files) === 0 && $EXPERT === TRUE)
if (count ($files) === 0 && $this->EXPERT === TRUE)
die ("No controllers/models available in ".getcwd()."\n");
foreach ($files as $file)
$classes[$file] = substr (strstr ($file, "_"), 1, -4);
@@ -115,7 +122,7 @@ class cli
echo "List of classes available :\n";
echo " ".implode ("\n ", $classes)."\n";
echo "Usage : ".$launcher;
if ($EXPERT) echo " -expert";
if ($this->EXPERT) echo " -expert";
echo " -listmethods <class>\n";
exit;
}
@@ -299,7 +306,7 @@ class cli
catch (Exception $e)
{
file_put_contents("php://stderr", $e->getMessage()."\n");
if ($EXPERT)
if ($this->EXPERT)
file_put_contents ("php://stderr", $e->getTraceAsString()."\n");
}
exit;