$parser->printHelp();
} else {
try {
+ foreach ($modular->getModules() as $module) {
+ $modular->getProvider()
+ ->getModule($module)
+ ->handleArguments($options, $arguments);
+ }
if (!empty($options['timed'])
&& class_exists('Horde_Support_Timer')) {
$timer = new Horde_Support_Timer();
--- /dev/null
+<?php
+/**
+ * The Horde_Kolab_Cli_Module:: interface describes the module structure for
+ * 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:: interface describes the module structure for
+ * 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
+ */
+interface Horde_Kolab_Cli_Module
+extends Horde_Cli_Modular_Module
+{
+ /**
+ * 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);
+}
\ No newline at end of file
* @link http://pear.horde.org/index.php?package=Cli_Modular
*/
class Horde_Kolab_Cli_Module_Base
-implements Horde_Cli_Modular_Module
+implements Horde_Kolab_Cli_Module
{
/**
* Get the usage description for this module.
{
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)
+ {
+ if (in_array($options['driver'], array('roundcube', 'php', 'pear'))) {
+ if (defined('E_DEPRECATED')) {
+ error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_NOTICE);
+ } else {
+ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
+ }
+ }
+ }
}
\ No newline at end of file
* @link http://pear.horde.org/index.php?package=Cli_Modular
*/
class Horde_Kolab_Cli_Module_Folder
-implements Horde_Cli_Modular_Module
+implements Horde_Kolab_Cli_Module
{
/**
* Get the usage description for this module.
}
/**
+ * 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.
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-12-16</date>
- <time>06:33:31</time>
+ <date>2010-12-21</date>
+ <time>07:16:30</time>
<version>
<release>0.0.1</release>
<api>0.0.1</api>
<file name="Base.php" role="php" />
<file name="Folder.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Cli/Module -->
+ <file name="Module.php" role="php" />
<file name="Translation.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Cli -->
<file name="Cli.php" role="php" />
<dir name="Cli">
<dir name="Unit">
<dir name="Cli">
+ <dir name="Module">
+ <file name="BaseTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Cli/Unit/Cli/Module -->
<file name="ModuleTest.php" role="test" />
<file name="OptionsTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Cli/Unit/Cli -->
<filelist>
<install as="klb" name="bin/klb" />
<install as="Horde/Kolab/Cli.php" name="lib/Horde/Kolab/Cli.php" />
+ <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/Unit/CliTest.php" name="test/Horde/Kolab/Cli/Unit/CliTest.php" />
<install as="Horde/Kolab/Cli/Unit/Cli/ModuleTest.php" name="test/Horde/Kolab/Cli/Unit/Cli/ModuleTest.php" />
<install as="Horde/Kolab/Cli/Unit/Cli/OptionsTest.php" name="test/Horde/Kolab/Cli/Unit/Cli/OptionsTest.php" />
+ <install as="Horde/Kolab/Cli/Unit/Cli/Module/BaseTest.php" name="test/Horde/Kolab/Cli/Unit/Cli/Module/BaseTest.php" />
<install as="COPYING" name="COPYING" />
</filelist>
</phprelease>
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-12-16</date>
+ <date>2010-12-21</date>
<license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
<notes>
* Initial release.
--- /dev/null
+<?php
+/**
+ * Test the base modules.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Cli
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Cli
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../../Autoload.php';
+
+/**
+ * Test the base modules.
+ *
+ * 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 Kolab
+ * @package Kolab_Cli
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Cli
+ */
+class Horde_Kolab_Cli_Unit_Cli_Module_BaseTest
+extends Horde_Kolab_Cli_TestCase
+{
+ public function setUp()
+ {
+ $this->_storeErrorHandling();
+ }
+
+ public function tearDown()
+ {
+ $this->_restoreErrorHandling();
+ }
+
+ public function testNotice()
+ {
+ $this->assertTrue((bool) (error_reporting() & E_NOTICE));
+ }
+
+ public function testMissingNoticeWithRoundcubeDriver()
+ {
+ $base = new Horde_Kolab_Cli_Module_Base();
+ $base->handleArguments(array('driver' => 'roundcube'), array());
+ $this->assertFalse((bool) (error_reporting() & E_NOTICE));
+ }
+
+ public function testMissingNoticeWithHordeDriver()
+ {
+ $base = new Horde_Kolab_Cli_Module_Base();
+ $base->handleArguments(array('driver' => 'horde'), array());
+ $this->assertTrue((bool) (error_reporting() & E_NOTICE));
+ }
+
+ private function _storeErrorHandling()
+ {
+ $this->_error_handling = error_reporting();
+ }
+
+ private function _restoreErrorHandling()
+ {
+ error_reporting($this->_error_handling);
+ }
+}