/** * Execute the CLI program * * Executes the setup() routine, adds default options, initiate the options parsing and argument checking * and finally executes main() */ public function run() { if ('cli' != php_sapi_name()) { throw new Exception('This has to be run from the command line'); } // setup $this->setup($this->options); $this->options->registerOption('no-colors', 'Do not use any colors in output. Useful when piping output to other tools or files.'); $this->options->registerOption('help', 'Display this help screen and exit immeadiately.', 'h'); // parse $this->options->parseOptions(); // handle defaults if ($this->options->getOpt('no-colors')) { $this->colors->disable(); } if ($this->options->getOpt('help')) { echo $this->options->help(); exit(0); } // check arguments $this->options->checkArguments(); // execute $this->main($this->options); exit(0); }