X-Git-Url: https://git.cweiske.de/bdrem.git/blobdiff_plain/6506b1ebe1ecaa6630d6d849c39b9e9d53603699..400a6537534c4083b39debdd9e49032daf093813:/src/bdrem/Cli.php diff --git a/src/bdrem/Cli.php b/src/bdrem/Cli.php index 2199161..f108e8e 100644 --- a/src/bdrem/Cli.php +++ b/src/bdrem/Cli.php @@ -5,33 +5,48 @@ class Cli extends UserInterface { protected function loadParameters() { - $params = $GLOBALS['argv']; - array_shift($params); - $storeInto = null; - foreach ($params as $param) { - if ($storeInto !== null) { - $this->config->$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_Mail(); - $r->config = $this->config; - $r->ansi = true; - echo $r->render($arEvents); + readfile(__DIR__ . '/../../data/bdrem.config.php.dist'); + exit(); } } ?>