From fcdd0bc0e9d35118090edbab933b2bd967f95076 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 11 Dec 2015 18:44:52 -0800 Subject: [PATCH] Reverted CleanCommand to pure Command --- system/src/Grav/Console/Cli/CleanCommand.php | 41 ++++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php index a5237e521..767406bfc 100644 --- a/system/src/Grav/Console/Cli/CleanCommand.php +++ b/system/src/Grav/Console/Cli/CleanCommand.php @@ -2,14 +2,24 @@ namespace Grav\Console\Cli; use Grav\Common\Filesystem\Folder; -use Grav\Console\ConsoleCommand; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; /** * Class CleanCommand * @package Grav\Console\Cli */ -class CleanCommand extends ConsoleCommand +class CleanCommand extends Command { + /* @var InputInterface $output */ + protected $input; + + /* @var OutputInterface $output */ + protected $output; + /** * @var array */ @@ -174,8 +184,10 @@ class CleanCommand extends ConsoleCommand /** * @return int|null|void */ - protected function serve() + protected function execute(InputInterface $input, OutputInterface $output) { + $this->setupConsole($input, $output); + $this->cleanPaths(); } @@ -183,12 +195,9 @@ class CleanCommand extends ConsoleCommand { $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); @@ -197,12 +206,30 @@ class CleanCommand extends ConsoleCommand $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, array('bold'))); + $this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, array('bold'))); + $this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan', null, array('bold'))); + $this->output->getFormatter()->setStyle('green', new OutputFormatterStyle('green', null, array('bold'))); + $this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta', null, array('bold'))); + $this->output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold'))); } }