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')); }
/** * 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; } }
/** * 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; } }
* Horde installer script. * * Copyright 2013 Horde LLC (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * * @author Michael Slusarz <*****@*****.**> * @category Horde * @copyright 2013 Horde LLC * @license http://www.fsf.org/copyleft/gpl.html GPL */ 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.');
/** * Write a message to the log. * * @param array $event Log event. * * @return boolean True. * @throws Horde_Log_Exception */ public function write($event) { $this->_cli->writeln($this->_formatter->format($event)); return true; }
/** * 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 = 'info'; } else { $action = $arguments[1]; } if (!isset($arguments[2])) { $folder_name = 'INBOX'; } else { $folder_name = $arguments[2]; } switch ($action) { case 'info': break; case 'synchronize': $world['storage']->getData($folder_name, $arguments[3])->synchronize(); break; case 'stamp': $cli->writeln((string) $world['storage']->getData($folder_name)->getStamp()); break; case 'complete': $data = $world['storage']->getData($folder_name); $complete = $data->fetchComplete($arguments[3]); $cli->writeln($complete[1]->toString(array('headers' => $complete[0]))); break; case 'part': $data = $world['storage']->getData($folder_name); $part = $data->fetchPart($arguments[3], $arguments[4]); rewind($part); $cli->writeln(quoted_printable_decode(stream_get_contents($part))); break; case 'fetch': $data = $world['storage']->getData($folder_name, $arguments[3]); $objects = $data->fetch(explode(',', $arguments[4])); foreach ($objects as $uid => $message) { $this->_yamlOutput($cli, $uid, $message); } break; case 'ids': $data = $world['storage']->getData($folder_name, $arguments[3]); foreach ($data->getObjectIds() as $id) { $cli->writeln((string) $id); } break; case 'objects': $data = $world['storage']->getData($folder_name, $arguments[3]); foreach ($data->getObjects() as $id => $object) { $this->_yamlOutput($cli, $id, $object); } break; case 'backendobjects': $data = $world['storage']->getData($folder_name, $arguments[3]); foreach ($data->getObjectsByBackendId() as $id => $object) { $this->_yamlOutput($cli, $id, $object); } break; case 'object': $data = $world['storage']->getData($folder_name, $arguments[3]); $object = $data->getObject($arguments[4]); $this->_yamlOutput($cli, $arguments[4], $object); break; case 'backendobject': $data = $world['storage']->getData($folder_name, $arguments[3]); $object = $data->getObjectByBackendId($arguments[4]); $this->_yamlOutput($cli, $arguments[4], $object); break; case 'create': $data = $world['storage']->getData($folder_name, $arguments[3]); switch (Horde_String::lower($arguments[4])) { case 'yaml': if (class_exists('Horde_Yaml')) { $object = Horde_Yaml::loadFile($arguments[5]); } else { throw new Horde_Kolab_Cli_Exception('The Horde_Yaml package is missing!'); } } $data->create($object); $cli->writeln($object['uid']); break; case 'move': $data = $world['storage']->getData($folder_name, $arguments[3]); $objects = $data->move($arguments[4], $arguments[5]); break; case 'delete': $data = $world['storage']->getData($folder_name, $arguments[3]); $objects = $data->delete(explode(',', $arguments[4])); break; case 'deleteall': $world['storage']->getData($folder_name, $arguments[3])->deleteAll(); break; case 'deleteuids': $data = $world['storage']->getData($folder_name, $arguments[3]); $objects = $data->deleteBackendIds(explode(',', $arguments[4])); break; case 'backendid': $data = $world['storage']->getData($folder_name, $arguments[3]); $cli->writeln((string) $data->getBackendId($arguments[4])); break; default: $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error'); break; } }
#!/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');