#!/usr/bin/env php
<?php
require "ConfigKit/ConfigCompiler.php";
require "ConfigKit/ConfigLoader.php";
require "FileUtil.php";
array_shift($argv);

use ConfigKit\ConfigCompiler;

foreach( $argv as $path ) {
    if ( is_file($path) ) {
        if ( ConfigCompiler::format_supported($path) ) {
            echo "Compiling $path\n";
            ConfigCompiler::load($path);
        }
    } elseif ( is_dir($path) ) {
        $files = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST); 
        foreach ($files as $file) {
            if ( $file->isFile() ) {
                $path = $file->getPathname();
                if ( ConfigCompiler::format_supported($path) ) {
                    echo "Compiling $path\n";
                    ConfigCompiler::load($path);
                }
            }
        }
    }
}

echo "Done";
