X-Git-Url: https://git.cweiske.de/bdrem.git/blobdiff_plain/21eb1d8202e756a2ccfd5ba4168f375ce995835e..deb49c81c9d269708c6252647c1afb668b982d97:/src/bdrem/Cli.php?ds=sidebyside diff --git a/src/bdrem/Cli.php b/src/bdrem/Cli.php index 807f336..f108e8e 100644 --- a/src/bdrem/Cli.php +++ b/src/bdrem/Cli.php @@ -1,26 +1,52 @@ load(); - setlocale(LC_TIME, $cfg->locale); - $source = $cfg->loadSource(); + $parser = parent::loadParameters(); + //set default renderer to console + $parser->options['renderer']->default = 'console'; - $arEvents = $source->getEvents( - date('Y-m-d'), $cfg->daysBefore, $cfg->daysAfter + //only on CLI + $parser->addCommand( + 'readme', array( + 'description' => 'Show README.rst file' + ) ); - usort($arEvents, '\\bdrem\\Event::compare'); - $this->render($arEvents); + $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(); } - public function render($arEvents) + protected function extractConfig() { - $r = new Renderer_Console(); - echo $r->render($arEvents); + readfile(__DIR__ . '/../../data/bdrem.config.php.dist'); + exit(); } } ?>