+++ /dev/null
-<?php
-/**
- * The Horde_Kolab_Cli_Module_Base:: module provides the base options of the
- * Kolab CLI.
- *
- * PHP version 5
- *
- * @category Horde
- * @package Cli_Modular
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Cli_Modular
- */
-
-/**
- * The Horde_Kolab_Cli_Module_Base:: module provides the base options of the
- * Kolab CLI.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Horde
- * @package Cli_Modular
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Cli_Modular
- */
-class Horde_Kolab_Cli_Module_Folder
-implements Horde_Kolab_Cli_Module
-{
- /**
- * Get the usage description for this module.
- *
- * @return string The description.
- */
- public function getUsage()
- {
- return Horde_Kolab_Cli_Translation::t(" folder - Handle folders
- - list [default]: List the folders in the backend
-");
- }
-
- /**
- * Get a set of base options that this module adds to the CLI argument
- * parser.
- *
- * @return array The options.
- */
- public function getBaseOptions()
- {
- return array();
- }
-
- /**
- * Indicate if the module provides an option group.
- *
- * @return boolean True if an option group should be added.
- */
- public function hasOptionGroup()
- {
- return false;
- }
-
- /**
- * Return the title for the option group representing this module.
- *
- * @return string The group title.
- */
- public function getOptionGroupTitle()
- {
- return '';
- }
-
- /**
- * Return the description for the option group representing this module.
- *
- * @return string The group description.
- */
- public function getOptionGroupDescription()
- {
- return '';
- }
-
- /**
- * Return the options for this module.
- *
- * @return array The group options.
- */
- public function getOptionGroupOptions()
- {
- return array();
- }
-
- /**
- * Handle the options and arguments.
- *
- * @param mixed &$options An array of options.
- * @param mixed &$arguments An array of arguments.
- *
- * @return NULL
- */
- public function handleArguments(&$options, &$arguments)
- {
- }
-
- /**
- * Run the module.
- *
- * @param Horde_Cli $cli The CLI handler.
- * @param mixed $options An array of options.
- * @param mixed $arguments An array of arguments.
- *
- * @return NULL
- */
- public function run($cli, $options, $arguments)
- {
- if (!isset($arguments[1])) {
- $action = 'list';
- } else {
- $action = $arguments[1];
- }
- switch ($action) {
- case 'list':
- $folders = $this->_getStorage($options)->getList()->listFolders();
- foreach ($folders as $folder) {
- $cli->writeln($folder);
- }
- break;
- case 'show':
- if (!isset($arguments[2])) {
- $folder_name = 'INBOX';
- } else {
- $folder_name = $arguments[2];
- }
- $folder = $this->_getStorage($options)->getFolder($folder_name);
- $cli->writeln('Path: ' . $folder->getPath());
- $cli->writeln('Title: ' . $folder->getTitle());
- $cli->writeln('Owner: ' . $folder->getOwner());
- $cli->writeln('Type: ' . $folder->getType());
- $cli->writeln('Namespace: ' . $folder->getNamespace());
- break;
- default:
- $cli->message(
- sprintf(
- Horde_Kolab_Cli_Translation::t('Action %s not supported!'),
- $action
- ),
- 'cli.error'
- );
- break;
- }
- }
-
- /**
- * Return the driver for the Kolab storage backend.
- *
- * @param mixed $options An array of options.
- *
- * @return Horde_Kolab_Storage The storage handler.
- */
- private function _getStorage($options)
- {
- $factory = new Horde_Kolab_Storage_Factory();
- return $factory->createFromParams(
- array(
- 'driver' => $options['driver'],
- 'params' => $options,
- 'logger' => isset($options['log']) ? $options['log'] : null,
- 'timelog' => isset($options['log']) && isset($options['timed']) ? $options['log'] : null,
- )
- );
- }
-}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * The Horde_Kolab_Cli_Module_List:: handles folder lists.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Cli_Modular
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Cli_Modular
+ */
+
+/**
+ * The Horde_Kolab_Cli_Module_List:: handles folder lists.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Cli_Modular
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Cli_Modular
+ */
+class Horde_Kolab_Cli_Module_List
+implements Horde_Kolab_Cli_Module
+{
+ /**
+ * Get the usage description for this module.
+ *
+ * @return string The description.
+ */
+ public function getUsage()
+ {
+ return Horde_Kolab_Cli_Translation::t(" list - Handle folder lists
+ - folders [default]: List the folders in the backend
+ - types : Display all folders that have a folder type.
+ - type TYPE : Display the folders of type TYPE.
+");
+ }
+
+ /**
+ * Get a set of base options that this module adds to the CLI argument
+ * parser.
+ *
+ * @return array The options.
+ */
+ public function getBaseOptions()
+ {
+ return array();
+ }
+
+ /**
+ * Indicate if the module provides an option group.
+ *
+ * @return boolean True if an option group should be added.
+ */
+ public function hasOptionGroup()
+ {
+ return false;
+ }
+
+ /**
+ * Return the title for the option group representing this module.
+ *
+ * @return string The group title.
+ */
+ public function getOptionGroupTitle()
+ {
+ return '';
+ }
+
+ /**
+ * Return the description for the option group representing this module.
+ *
+ * @return string The group description.
+ */
+ public function getOptionGroupDescription()
+ {
+ return '';
+ }
+
+ /**
+ * Return the options for this module.
+ *
+ * @return array The group options.
+ */
+ public function getOptionGroupOptions()
+ {
+ return array();
+ }
+
+ /**
+ * Handle the options and arguments.
+ *
+ * @param mixed &$options An array of options.
+ * @param mixed &$arguments An array of arguments.
+ *
+ * @return NULL
+ */
+ public function handleArguments(&$options, &$arguments)
+ {
+ }
+
+ /**
+ * Run the module.
+ *
+ * @param Horde_Cli $cli The CLI handler.
+ * @param mixed $options An array of options.
+ * @param mixed $arguments An array of arguments.
+ *
+ * @return NULL
+ */
+ public function run($cli, $options, $arguments)
+ {
+ if (!isset($arguments[1])) {
+ $action = 'folders';
+ } else {
+ $action = $arguments[1];
+ }
+ switch ($action) {
+ case 'folders':
+ $folders = $this->_getStorage($options)->getList()->listFolders();
+ foreach ($folders as $folder) {
+ $cli->writeln($folder);
+ }
+ break;
+ case 'types':
+ $types = $this->_getStorage($options)->getList()->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 = $this->_getStorage($options)
+ ->getList()
+ ->getQuery('Base')
+ ->listByType($type);
+ foreach ($folders as $folder) {
+ $cli->writeln($folder);
+ }
+ break;
+ case 'show':
+ if (!isset($arguments[2])) {
+ $folder_name = 'INBOX';
+ } else {
+ $folder_name = $arguments[2];
+ }
+ $folder = $this->_getStorage($options)->getFolder($folder_name);
+ $cli->writeln('Path: ' . $folder->getPath());
+ $cli->writeln('Title: ' . $folder->getTitle());
+ $cli->writeln('Owner: ' . $folder->getOwner());
+ $cli->writeln('Type: ' . $folder->getType());
+ $cli->writeln('Namespace: ' . $folder->getNamespace());
+ break;
+ default:
+ $cli->message(
+ sprintf(
+ Horde_Kolab_Cli_Translation::t('Action %s not supported!'),
+ $action
+ ),
+ 'cli.error'
+ );
+ break;
+ }
+ }
+
+ /**
+ * Return the driver for the Kolab storage backend.
+ *
+ * @param mixed $options An array of options.
+ *
+ * @return Horde_Kolab_Storage The storage handler.
+ */
+ private function _getStorage($options)
+ {
+ $factory = new Horde_Kolab_Storage_Factory();
+ return $factory->createFromParams(
+ array(
+ 'driver' => $options['driver'],
+ 'params' => $options,
+ 'logger' => isset($options['log']) ? $options['log'] : null,
+ 'timelog' => isset($options['log']) && isset($options['timed']) ? $options['log'] : null,
+ )
+ );
+ }
+}
\ No newline at end of file
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-12-21</date>
- <time>07:16:30</time>
+ <date>2010-12-29</date>
+ <time>11:02:02</time>
<version>
<release>0.0.1</release>
<api>0.0.1</api>
<dir name="Cli">
<dir name="Module">
<file name="Base.php" role="php" />
- <file name="Folder.php" role="php" />
+ <file name="List.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Cli/Module -->
<file name="Module.php" role="php" />
<file name="Translation.php" role="php" />
<channel>pear.horde.org</channel>
</package>
<package>
+ <name>Util</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Log</name>
<channel>pear.horde.org</channel>
</package>
<install as="Horde/Kolab/Cli/Module.php" name="lib/Horde/Kolab/Cli/Module.php" />
<install as="Horde/Kolab/Cli/Translation.php" name="lib/Horde/Kolab/Cli/Translation.php" />
<install as="Horde/Kolab/Cli/Module/Base.php" name="lib/Horde/Kolab/Cli/Module/Base.php" />
- <install as="Horde/Kolab/Cli/Module/Folder.php" name="lib/Horde/Kolab/Cli/Module/Folder.php" />
+ <install as="Horde/Kolab/Cli/Module/List.php" name="lib/Horde/Kolab/Cli/Module/List.php" />
<install as="Horde/Kolab/Cli/AllTests.php" name="test/Horde/Kolab/Cli/AllTests.php" />
<install as="Horde/Kolab/Cli/Autoload.php" name="test/Horde/Kolab/Cli/Autoload.php" />
<install as="Horde/Kolab/Cli/phpunit.xml" name="test/Horde/Kolab/Cli/phpunit.xml" />
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-12-21</date>
+ <date>2010-12-29</date>
<license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
<notes>
* Initial release.