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