message() public méthode

Displays a message.
public message ( $message, string $type = 'cli.message' )
$type string The type of message: 'cli.error', 'cli.warning', 'cli.success', or 'cli.message'.
Exemple #1
0
 public function pear($text)
 {
     if (!$this->_verbose) {
         return;
     }
     $this->_cli->message('-------------------------------------------------', $this->_getType('cli.message'));
     $this->_cli->message('PEAR output START', $this->_getType('cli.message'));
     $this->_cli->message('-------------------------------------------------', $this->_getType('cli.message'));
     $this->_cli->writeln($text);
     $this->_cli->message('-------------------------------------------------', $this->_getType('cli.message'));
     $this->_cli->message('PEAR output END', $this->_getType('cli.message'));
     $this->_cli->message('-------------------------------------------------', $this->_getType('cli.message'));
 }
Exemple #2
0
 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'read';
     } else {
         $action = $arguments[1];
     }
     switch ($action) {
         case 'read':
             $parser = $world['format']->create('Xml', $arguments[2]);
             if (empty($arguments[4])) {
                 if (file_exists($arguments[3])) {
                     $contents = file_get_contents($arguments[3]);
                     $data = $parser->load($contents);
                     $id = $arguments[3];
                 } else {
                     $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('%s is no local file!'), $arguments[3]), 'cli.error');
                 }
             } else {
                 $ks_data = $world['storage']->getData($arguments[3]);
                 $part = $ks_data->fetchPart($arguments[4], $arguments[5]);
                 rewind($part);
                 $xml = quoted_printable_decode(stream_get_contents($part));
                 $data = $parser->load($xml);
                 $id = $arguments[3] . ':' . $arguments[4] . '[' . $arguments[5] . ']';
             }
             if (class_exists('Horde_Yaml')) {
                 $this->_formatOutput($cli, $id, Horde_Yaml::dump($data));
             } else {
                 $this->_formatOutput($cli, $id, print_r($data, true));
             }
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
Exemple #3
0
 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'folders';
     } else {
         $action = $arguments[1];
     }
     switch ($action) {
         case 'folders':
             $folders = $world['storage']->getList()->listFolders();
             foreach ($folders as $folder) {
                 $cli->writeln($folder);
             }
             break;
         case 'types':
             $types = $world['storage']->getList()->getQuery()->listTypes();
             if (!empty($types)) {
                 $pad = max(array_map('strlen', array_keys($types))) + 2;
                 foreach ($types as $folder => $type) {
                     $cli->writeln(Horde_String::pad($folder . ':', $pad) . $type);
                 }
             }
             break;
         case 'type':
             if (!isset($arguments[2])) {
                 throw new Horde_Kolab_Cli_Exception('You must provide a TYPE argument!');
             }
             $type = $arguments[2];
             $folders = $world['storage']->getList()->getQuery()->listByType($type);
             foreach ($folders as $folder) {
                 $cli->writeln($folder);
             }
             break;
         case 'owners':
             $owners = $world['storage']->getList()->getQuery()->listOwners();
             if (!empty($owners)) {
                 $pad = max(array_map('strlen', array_keys($owners))) + 2;
                 foreach ($owners as $folder => $owner) {
                     $cli->writeln(Horde_String::pad($folder . ':', $pad) . $owner);
                 }
             }
             break;
         case 'defaults':
             $defaults = $world['storage']->getList()->getQuery()->listDefaults();
             if (!empty($defaults)) {
                 foreach ($defaults as $owner => $folders) {
                     $cli->writeln('User "' . $owner . '":');
                     $cli->writeln();
                     foreach ($folders as $type => $folder) {
                         $cli->writeln('  ' . Horde_String::pad($type . ':', 14) . $folder);
                     }
                     $cli->writeln();
                 }
             }
             break;
         case 'aclsupport':
             if ($world['storage']->getList()->getQuery(Horde_Kolab_Storage_List::QUERY_ACL)->hasAclSupport()) {
                 echo "The remote server supports ACL.\n";
             } else {
                 echo "The remote server does not support ACL.\n";
             }
             break;
         case 'namespaces':
             $cli->writeln((string) $world['storage']->getList()->getNamespace());
             break;
         case 'sync':
             $folders = $world['storage']->getList()->synchronize();
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
Exemple #4
0
 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'display';
     } else {
         $action = $arguments[1];
     }
     switch ($action) {
         case 'display':
             $folders = $world['storage']->getList()->getQuery()->listByType('h-ledger');
             foreach ($folders as $folder) {
                 $cli->writeln($folder);
             }
             break;
             break;
         case 'import':
             $ledger = new Horde_Kolab_Cli_Data_Ledger();
             $ledger->importFile($arguments[3]);
             $data = $world['storage']->getData($arguments[2], 'h-ledger');
             $object = array('type' => 'h-ledger');
             foreach ($ledger->asXml() as $entry) {
                 $object['xml'] = $entry;
                 $data->create($object);
             }
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
Exemple #5
0
require 'vendor/autoload.php';
require 'lib/HordeInstaller.php';
$c = new Horde_Cli();
$c->writeln($c->bold('----------------------'));
$c->writeln($c->bold('Horde installer script'));
$c->writeln($c->bold('----------------------'));
$argv = new Horde_Argv_Parser();
$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) {
Exemple #6
0
#!/usr/bin/env php
<?php 
/**
 * @package Cli
 */
require 'Horde/Cli.php';
$cli = new Horde_Cli();
/* Explicit colors */
$cli->writeln($cli->red('Red'));
$cli->writeln($cli->yellow('Yellow'));
$cli->writeln($cli->green('Green'));
$cli->writeln($cli->blue('Blue'));
$cli->writeln();
/* These messages are automatically colorized based on the message type. */
$cli->message('test', 'cli.error');
$cli->message('test', 'cli.warning');
$cli->message('test', 'cli.success');
$cli->message('test', 'cli.message');