setName("clean")
->setDescription("Handles cleaning chores for Grav distribution")
->setHelp('The clean clean extraneous folders and data');
}
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$this->cleanPaths();
}
private function cleanPaths()
{
$this->output->writeln('');
$this->output->writeln('DELETING');
$anything = false;
foreach ($this->paths_to_remove as $path) {
$path = ROOT_DIR . $path;
if (is_dir($path) && @Folder::delete($path)) {
$anything = true;
$this->output->writeln('dir: ' . $path);
} elseif (is_file($path) && @unlink($path)) {
$anything = true;
$this->output->writeln('file: ' . $path);
}
}
if (!$anything) {
$this->output->writeln('');
$this->output->writeln('Nothing to clean...');
}
}
/**
* Set colors style definition for the formatter.
*
* @param InputInterface $input
* @param OutputInterface $output
*/
public function setupConsole(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$this->output->getFormatter()->setStyle('normal', new OutputFormatterStyle('white'));
$this->output->getFormatter()->setStyle('yellow', new OutputFormatterStyle('yellow', null, ['bold']));
$this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, ['bold']));
$this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, ['bold']));
$this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, ['bold']));
$this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, ['bold']));
$this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, ['bold']));
}
}