function actionCreate($args) { if (count($args) == 0) { echo "Usage:\n\n"; echo ' ' . C_BOLD . C_GREEN . 'create' . C_RESET . ' ' . C_BLUE . '<path>' . C_RESET . "\n"; return; } nf_xcopy(realpath(dirname(__FILE__)) . '/skeleton', $args[0], array('skeleton/index.php')); $index = file_get_contents(realpath(dirname(__FILE__)) . '/skeleton/index.php'); $index = str_replace('/*NF_PHP*/', '\'' . addslashes(__DIR__ . '/nf.php') . '\'', $index); file_put_contents($args[0] . '/index.php', $index); echo C_BOLD . C_GREEN . 'Done!' . C_RESET . ' Skeleton project created in ' . C_BLUE . $args[0] . C_RESET . "\n"; }
function nf_xcopy($src, $dst, $ignore = array()) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { nf_xcopy($src . '/' . $file, $dst . '/' . $file, $ignore); } elseif (array_search($src . '/' . $file, $ignore) === false) { copy($src . '/' . $file, $dst . '/' . $file); } } } closedir($dir); }