private function initializeNewProject()
{
$path = isset($this->getParseResult()->command->args['path']) ? $this->getParseResult()->command->args['path'] : \getcwd() . '/.phrozn';
$config = $this->getConfig();
if (!$this->isAbsolute($path)) {
// not an absolute path
$path = \getcwd() . '/./' . $path;
}
ob_start();
$this->out($this->getHeader());
$this->out("Initializing new project");
$this->out("\n Project path: {$path}");
if (is_dir($path)) {
$this->out(self::STATUS_FAIL . "Project directory '" . basename($path) . "' already exists..");
$this->out($this->pad(self::STATUS_FAIL) . "Type 'phrozn help clobber' to get help on removing existing project.");
return $this->out($this->getFooter());
} else {
if (!@mkdir($path)) {
$this->out(self::STATUS_FAIL . "Error creating project directory..");
return $this->out($this->getFooter());
}
}
// copy skeleton to newly inited project
$skeletonPath = $config['paths']['skeleton'];
$this->copy($skeletonPath, $path, function ($that, $destPath, $status) use($path) {
$destPath = str_replace('//', '/', $destPath);
$destPath = str_replace($path, '', $destPath);
if ($status) {
$that->out(Base::STATUS_ADDED . "{$destPath}");
} else {
$that->out(Base::STATUS_FAIL . "{$destPath}");
}
});
return $this->out($this->getFooter());
}