summaryrefslogtreecommitdiff
path: root/framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php
diff options
context:
space:
mode:
authorwei <>2006-09-18 22:57:16 +0000
committerwei <>2006-09-18 22:57:16 +0000
commit1e5f13b21b33b0d7ce86fe97ca145a3561433a7a (patch)
tree0d578ace6150cf69478696737cf0e1156a309661 /framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php
parent8e3f638109ebdb4bedc3e9ed7360b9d2467bc311 (diff)
Add an interactive php shell that loads Prado classes.
Diffstat (limited to 'framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php')
-rw-r--r--framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php
new file mode 100644
index 00000000..843292b0
--- /dev/null
+++ b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/VerbosePrint.php
@@ -0,0 +1,56 @@
+<?php
+class PHP_Shell_Extensions_VerbosePrint implements PHP_Shell_Extension {
+ protected $opt_verbose = false;
+ protected $oneshot_verbose = false;
+
+ public function register() {
+ $cmd = PHP_Shell_Commands::getInstance();
+ $cmd->registerCommand('#^p #', $this, 'cmdPrint', 'p <var>', 'print the variable verbosly');
+
+ $opt = PHP_Shell_Options::getInstance();
+ $opt->registerOption('verboseprint', $this, 'optSetVerbose');
+
+ }
+
+ /**
+ * handle the 'p ' command
+ *
+ * set the verbose flag
+ *
+ * @return string the pure command-string without the 'p ' command
+ */
+ public function cmdPrint($l) {
+ $this->oneshot_verbose = true;
+
+ $cmd = substr($l, 2);
+
+ return $cmd;
+ }
+
+ public function optSetVerbose($key, $val) {
+ switch($val) {
+ case "false":
+ case "on":
+ case "1":
+ $this->opt_verbose = true;
+ default:
+ $this->opt_verbose = false;
+ break;
+ }
+ }
+
+ /**
+ * check if we have a verbose print-out
+ *
+ * @return bool 1 if verbose, 0 otherwise
+ */
+ public function isVerbose() {
+ $v = $this->opt_verbose || $this->oneshot_verbose;
+
+ $this->oneshot_verbose = false;
+
+ return $v;
+ }
+}
+
+