9 * @author Christian Weiske <cweiske@cweiske.de>
10 * @copyright 2014 Christian Weiske
11 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
12 * @link http://cweiske.de/bdrem.htm
17 * Command line user interface for the terminal/shell.
18 * Renders an ASCII table by default.
22 * @author Christian Weiske <cweiske@cweiske.de>
23 * @copyright 2014 Christian Weiske
24 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
25 * @version Release: @package_version@
26 * @link http://cweiske.de/bdrem.htm
28 class Cli extends UserInterface
31 * Load parameters for the CLI option parser.
32 * Set the default renderer to "console" and adds some CLI-only commands
33 * like "readme" and "config".
35 * @return \Console_CommandLine CLI option parser
37 protected function loadParameters()
39 $parser = parent::loadParameters();
40 //set default renderer to console
41 $parser->options['renderer']->default = 'console';
46 'description' => 'Show README.rst file'
51 'description' => 'Extract configuration file'
59 * Handle any commands given on the CLI
61 * @param object $res Command line parameters and options
65 protected function handleCommands($res)
67 if ($res->command_name == '') {
69 } else if ($res->command_name == 'readme') {
71 } else if ($res->command_name == 'config') {
72 $this->extractConfig();
74 throw new \Exception('Unknown command');
79 * Handle the "readme" command and output the readme.
83 protected function showReadme()
85 readfile(__DIR__ . '/../../README.rst');
90 * Handle the "config" command and output the default configuration
94 protected function extractConfig()
96 readfile(__DIR__ . '/../../data/bdrem.config.php.dist');