summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2002-03-19 19:28:48 +0000
committerStig Bakken <ssb@php.net>2002-03-19 19:28:48 +0000
commit529ec7cda45f2f11dc74700e4cea533d115baf72 (patch)
tree8ba4b1bd274285767b4cb45791959d56a1e94238
parenta9411a6da26b1db439bb7111ef0d84ad3bb02464 (diff)
downloadphp-git-529ec7cda45f2f11dc74700e4cea533d115baf72.tar.gz
* add optional default parameter to userDialog method
-rw-r--r--pear/PEAR/CommandUI/CLI.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/pear/PEAR/CommandUI/CLI.php b/pear/PEAR/CommandUI/CLI.php
index 816abde4b4..76ea6f6baf 100644
--- a/pear/PEAR/CommandUI/CLI.php
+++ b/pear/PEAR/CommandUI/CLI.php
@@ -25,12 +25,16 @@ class PEAR_CommandUI_CLI extends PEAR
print "$text\n";
}
- function userDialog($prompt, $type = 'text')
+ function userDialog($prompt, $type = 'text', $default = '')
{
if ($type == 'password') {
system('stty -echo');
}
- print "$prompt : ";
+ print "$prompt ";
+ if ($default) {
+ print "[$default] ";
+ }
+ print ": ";
$fp = fopen("php://stdin", "r");
$line = fgets($fp, 2048);
fclose($fp);
@@ -38,6 +42,9 @@ class PEAR_CommandUI_CLI extends PEAR
system('stty echo');
print "\n";
}
+ if ($default && trim($line) == "") {
+ return $default;
+ }
return $line;
}