show error, not exception
[bdrem.git] / src / bdrem / Cli.php
index ec849f42cac05f8267326ed1c8d9efc52a8c2eef..f108e8e4b8b48cff5567458051538c172054bac0 100644 (file)
@@ -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();
+    }
 }
 ?>