class Cli extends UserInterface
{
- protected function loadParameters($cfg)
+ protected function loadParameters()
{
- $params = $GLOBALS['argv'];
- array_shift($params);
- $storeInto = null;
- foreach ($params as $param) {
- if ($storeInto !== null) {
- $cfg->$storeInto = (int)$param;
- $storeInto = null;
- continue;
- }
+ $parser = parent::loadParameters();
+ //set default renderer to console
+ $parser->options['renderer']->default = 'console';
- if ($param == '--days-after' || $param == '-a') {
- $storeInto = 'daysAfter';
- continue;
- } else if ($param == '--days-before' || $param == '-b') {
- $storeInto = 'daysBefore';
- continue;
- }
- $storeInto = null;
+ //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 render($arEvents)
+ protected function showReadme()
+ {
+ readfile(__DIR__ . '/../../README.rst');
+ exit();
+ }
+
+ protected function extractConfig()
{
- $r = new Renderer_Console();
- $r->ansi = true;
- echo $r->render($arEvents);
+ readfile(__DIR__ . '/../../data/bdrem.config.php.dist');
+ exit();
}
}
?>