PhpPeg\ParserCompiler::cli PHP Method

cli() static public method

static public cli ( $args )
    static function cli($args)
    {
        if (count($args) == 1) {
            print "Parser Compiler: A compiler for PEG parsers in PHP \n";
            print "(C) 2009 SilverStripe. See COPYING for redistribution rights. \n";
            print "\n";
            print "Usage: {$args[0]} infile [ outfile ]\n";
            print "\n";
        } else {
            $fname = $args[1] == '-' ? 'php://stdin' : $args[1];
            $string = file_get_contents($fname);
            $string = self::compile($string);
            if (!empty($args[2]) && $args[2] != '-') {
                file_put_contents($args[2], $string);
            } else {
                print $string;
            }
        }
    }