/** * Invokes the command. * * Needs opts like: getopt("s:f:o:hd"). * Returns error codes defined as class constants. * * @param array $opts Command line arguments. * @param string $baseName Teh script which invokes the command, default is 'ebnf'. * * @return int */ public static function main(array $opts, $baseName = "ebnf") { $debug = false; if (isset($opts["d"])) { $debug = true; } try { $self = new Command($opts, $baseName); return $self->execute(); } catch (SyntaxtException $e) { echo "{$e}\n"; if ($debug) { echo "{$e->getTraceAsString()}\n"; } return self::EBNF_SYNTAX_ERROR; } catch (Exception $e) { echo "Error: {$e->getMessage()}\n"; if ($debug) { echo "{$e->getTraceAsString()}\n"; } return self::EBNF_FATAL_ERROR; } }
#!/usr/bin/env php <?php /** * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @author Vincent Tscherter <*****@*****.**> * @author Sven Strittmatter <*****@*****.**> */ namespace de\weltraumschaf\ebnf; use Exception; require_once dirname(__DIR__) . "/src/Command.php"; exit(Command::main(getopt("s:f:o:hd"), basename(__FILE__)));