diff options
-rw-r--r-- | pear/PEAR/CommandUI/CLI.php | 11 |
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; } |