diff --git a/cli.php b/cli.php index 43fb71a..4c56e96 100644 --- a/cli.php +++ b/cli.php @@ -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 \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;