X-Git-Url: https://git.cweiske.de/bdrem.git/blobdiff_plain/441c72bbf3d29be5c7f5eb0fd43ac267fe059c2f..400a6537534c4083b39debdd9e49032daf093813:/src/bdrem/Cli.php diff --git a/src/bdrem/Cli.php b/src/bdrem/Cli.php index 5ab5ec8..f108e8e 100644 --- a/src/bdrem/Cli.php +++ b/src/bdrem/Cli.php @@ -1,21 +1,52 @@ load(); - $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'); + $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'); + } + } - $r = new Renderer_Console(); - echo $r->render($arEvents); + protected function showReadme() + { + readfile(__DIR__ . '/../../README.rst'); + exit(); + } + + protected function extractConfig() + { + readfile(__DIR__ . '/../../data/bdrem.config.php.dist'); + exit(); } } ?>