Remove manual phar building scripts
[bdrem.git] / src / bdrem / Cli.php
1 <?php
2 namespace bdrem;
3
4 class Cli extends UserInterface
5 {
6     protected function loadParameters()
7     {
8         $parser = parent::loadParameters();
9         //set default renderer to console
10         $parser->options['renderer']->default = 'console';
11
12         //only on CLI
13         $parser->addCommand(
14             'readme', array(
15                 'description' => 'Show README.rst file'
16             )
17         );
18         $parser->addCommand(
19             'config', array(
20                 'description' => 'Extract configuration file'
21             )
22         );
23
24         return $parser;
25     }
26
27     protected function handleCommands($res)
28     {
29         if ($res->command_name == '') {
30             return;
31         } else if ($res->command_name == 'readme') {
32             $this->showReadme();
33         } else if ($res->command_name == 'config') {
34             $this->extractConfig();
35         } else {
36             throw new \Exception('Unknown command');
37         }
38     }
39
40     protected function showReadme()
41     {
42         readfile(__DIR__ . '/../../README.rst');
43         exit();
44     }
45
46     protected function extractConfig()
47     {
48         readfile(__DIR__ . '/../../data/bdrem.config.php.dist');
49         exit();
50     }
51 }
52 ?>