From 83afda94b7d5fc2be341712e2661f6095f608e0d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 25 Feb 2014 07:46:37 +0100 Subject: commands to show readme and extract config template --- src/bdrem/Cli.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/bdrem/Cli.php') diff --git a/src/bdrem/Cli.php b/src/bdrem/Cli.php index ec849f4..f108e8e 100644 --- a/src/bdrem/Cli.php +++ b/src/bdrem/Cli.php @@ -9,7 +9,44 @@ class Cli extends UserInterface //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(); + } } ?> -- cgit v1.2.3