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 'long_name' => '--no-color',
47 'description' => 'Do not output ANSI color codes',
48 'action' => 'StoreFalse',
56 'description' => 'Show README.rst file'
61 'description' => 'Extract configuration file'
69 * Handle any commands given on the CLI
71 * @param object $res Command line parameters and options
75 protected function handleCommands($res)
77 if ($res->command_name == '') {
79 } else if ($res->command_name == 'readme') {
81 } else if ($res->command_name == 'config') {
82 $this->extractConfig();
84 throw new \Exception('Unknown command');
89 * Handle the "readme" command and output the readme.
93 protected function showReadme()
95 readfile(__DIR__ . '/../../README.rst');
100 * Handle the "config" command and output the default configuration
104 protected function extractConfig()
106 readfile(__DIR__ . '/../../data/bdrem.config.php.dist');