$parser->printHelp();
} else {
try {
+ if (!empty($options['timed'])
+ && class_exists('Horde_Support_Timer')) {
+ $timer = new Horde_Support_Timer();
+ $timer->push();
+ } else {
+ $timer = false;
+ }
$modular->getProvider()
->getModule(ucfirst($arguments[0]))
- ->run($options, $arguments);
+ ->run($cli, $options, $arguments);
+ if (!empty($options['timed'])) {
+ if ($timer) {
+ $cli->message(floor($timer->pop() * 1000) . ' ms');
+ } else {
+ $cli->message('The class Horde_Support_Timer seems to be missing!');
+ }
+ }
} catch (Horde_Cli_Modular_Exception $e) {
$parser->printHelp();
}
'help' => Horde_Kolab_Cli_Translation::t('The host that holds the data.')
)
),
+ new Horde_Argv_Option(
+ '-t',
+ '--timed',
+ array(
+ 'action' => 'store_true',
+ 'help' => Horde_Kolab_Cli_Translation::t('Produce time measurements to indicate how long the processing takes.')
+ )
+ ),
);
}
<channel>pear.horde.org</channel>
</package>
</required>
+ <optional>
+ <package>
+ <name>Support</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ </optional>
</dependencies>
<phprelease>
<filelist>
$this->runCli()
);
}
+
+ public function testOptionTimed()
+ {
+ $_SERVER['argv'] = array(
+ 'klb'
+ );
+ $this->assertRegExp(
+ '/-t,[ ]*--timed/',
+ $this->runCli()
+ );
+ }
}
);
$this->assertContains('INBOX', $this->runCli());
}
+
+ public function testTimeInfo()
+ {
+ $_SERVER['argv'] = array(
+ 'klb',
+ '--driver=mock',
+ '--timed',
+ '--user=test',
+ 'folder'
+ );
+ $this->assertContains('[ INFO ]', $this->runCli());
+ }
+
+ public function testTimed()
+ {
+ $_SERVER['argv'] = array(
+ 'klb',
+ '--driver=mock',
+ '--timed',
+ '--user=test',
+ 'folder'
+ );
+ $this->assertRegExp('/\[ INFO \] [0-9]+ ms/', $this->runCli());
+ }
+
+ public function testTimeMissing()
+ {
+ $_SERVER['argv'] = array(
+ 'klb',
+ '--driver=mock',
+ '--user=test',
+ 'folder'
+ );
+ $this->assertNotContains('[ INFO ]', $this->runCli());
+ }
}