<?php

App::uses('Folder', 'Utility');
App::uses('File', 'Utility');

/**
 * Use:
 * $ cd {SITE_FOLDER}/app
 * $ ./Console/cake bake_lookup
 */
class BakeLookupShell {

    public function main() {

        $dir = new Folder(ROOT.DS.APP_DIR.DS.'Console'.DS.'Templates');
        $files = $dir->find('.*\.php');

        foreach ($files as $file) {

            $this->out($file);
            $file = new File($dir->pwd() . DS . $file);
            $contents = $file->read();
            $file->write('I am overwriting the contents of this file');
            $file->append('I am adding to the bottom of this file.');
            $file->delete(); // I am deleting this file
            $file->close(); // Be sure to close the file when you're done
        }
    }

}
