Beispiel #1
0
 public function execute($args)
 {
     array_shift($args);
     // Remove the script name
     if (count($args) >= 2) {
         $name = ucfirst($args[1]);
         foreach (Clips\config('peg_dir') as $peg_dir) {
             $file = Clips\try_path(Clips\path_join($peg_dir, $name . '.peg'));
             if ($file) {
                 break;
             }
         }
         if (!$file) {
             $this->error('No peg file found ');
             return;
         } else {
             $args[1] = $file;
         }
         foreach (Clips\config('library_dir') as $lib_dir) {
             $out_dir = Clips\try_path($lib_dir);
             if ($out_dir) {
                 break;
             }
         }
         if ($out_dir) {
             $out = Clips\path_join($out_dir, $name . '.php');
             $args[2] = $out;
             $this->output('Writing file %s.', $out);
         }
     }
     Compiler::cli($args);
 }
Beispiel #2
0
<?php

require 'autoloader.php';
use hafriedlander\Peg\Compiler;
Compiler::cli($_SERVER['argv']);