Prompts for a user response.
public prompt ( string $prompt, array $choices = null, string $default = null ) : mixed | ||
$prompt | string | The message to display when prompting the user. |
$choices | array | The choices available to the user or null for a text input. |
$default | string | The default value if no value specified. |
return | mixed | The user's response to the prompt. |
$argv->addOption('-i', '--install-dir', array('action' => 'store', 'dest' => 'horde_dir', 'help' => 'Horde install directory')); $argv->addOption('-l', '--log', array('action' => 'store', 'dest' => 'log', 'help' => 'Log filename')); list($values, ) = $argv->parseArgs(); $version = phpversion(); if (version_compare($version, '5.3.0') === -1) { $c->fatal('You need at least PHP version 5.3.0 to run Horde.'); } $c->writeln(); $c->message('PHP version: ' . $version, 'cli.message'); exec('which pear', $pear_output); if (empty($pear_output)) { $c->fatal('Could not find PEAR script in your include path.'); } $c->message('PEAR location: ' . $pear_output[0], 'cli.message'); while (!strlen($values->horde_dir)) { $values->horde_dir = $c->prompt('The directory to install Horde into:'); } $hi = new HordeInstaller(); $logfile = isset($values->log) ? realpath($values->log) : dirname(Phar::running(false)) . '/horde-installer.log'; $c->writeln(); try { $hi->initLogger($logfile); $c->message('Log file: ' . $logfile, 'cli.message'); } catch (Exception $e) { $c->message(sprintf('Cannot write to log file "%s".', $logfile), 'cli.warning'); } $c->writeln(); $c->message('Upgrading PEAR to the latest version...', 'cli.message'); $hi->pear('pear upgrade PEAR'); $c->message('Success.', 'cli.success'); $c->writeln();