//set default renderer to console
$parser->options['renderer']->default = 'console';
+ //only on CLI
+ $parser->addCommand(
+ 'readme', array(
+ 'description' => 'Show README.rst file'
+ )
+ );
+ $parser->addCommand(
+ 'config', array(
+ 'description' => 'Extract configuration file'
+ )
+ );
+
return $parser;
}
+
+ protected function handleCommands($res)
+ {
+ if ($res->command_name == '') {
+ return;
+ } else if ($res->command_name == 'readme') {
+ $this->showReadme();
+ } else if ($res->command_name == 'config') {
+ $this->extractConfig();
+ } else {
+ throw new \Exception('Unknown command');
+ }
+ }
+
+ protected function showReadme()
+ {
+ readfile(__DIR__ . '/../../README.rst');
+ exit();
+ }
+
+ protected function extractConfig()
+ {
+ readfile(__DIR__ . '/../../data/bdrem.config.php.dist');
+ exit();
+ }
}
?>
setlocale(LC_TIME, $this->config->locale);
$parser = $this->loadParameters();
- $this->parseParameters($parser);
+ $res = $this->parseParameters($parser);
+ $this->handleCommands($res);
if (!$this->config->cfgFileExists) {
throw new \Exception('No config file found');
$this->config->renderer = $result->options['renderer'];
$this->config->stopOnEmpty = $result->options['stopOnEmpty'];
$this->config->setDate($result->options['date']);
+ return $result;
} catch (\Exception $exc) {
$this->preRenderParameterError();
$parser->displayError($exc->getMessage());
return new $class();
}
+ protected function handleCommands($res)
+ {
+ }
+
protected function preRenderParameterError()
{
}