Commit 7411ca35 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] More work on CLI Tasks. Implemented HelpTask.

parent 2442cfa8
...@@ -156,6 +156,10 @@ class Cli ...@@ -156,6 +156,10 @@ class Cli
$processedArgs = $this->_processArguments($args); $processedArgs = $this->_processArguments($args);
try { try {
$this->_printer->writeln(
'Doctrine Command Line Interface' . PHP_EOL, 'HEADER'
);
// Handle possible multiple tasks on a single command // Handle possible multiple tasks on a single command
foreach($processedArgs as $taskData) { foreach($processedArgs as $taskData) {
// Retrieve the task name and arguments // Retrieve the task name and arguments
...@@ -182,7 +186,7 @@ class Cli ...@@ -182,7 +186,7 @@ class Cli
} }
} }
} catch (\Doctrine\Common\DoctrineException $e) { } catch (\Doctrine\Common\DoctrineException $e) {
$this->_printer->write( $this->_printer->writeln(
$taskName . ':' . $e->getMessage() . PHP_EOL, 'ERROR' $taskName . ':' . $e->getMessage() . PHP_EOL, 'ERROR'
); );
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
namespace Doctrine\ORM\Tools\Cli\Tasks; namespace Doctrine\ORM\Tools\Cli\Tasks;
use Doctrine\Common\Util\Inflector;
/** /**
* CLI Task to display available commands help * CLI Task to display available commands help
* *
...@@ -39,11 +41,7 @@ class HelpTask extends AbstractTask ...@@ -39,11 +41,7 @@ class HelpTask extends AbstractTask
*/ */
public function extendedHelp() public function extendedHelp()
{ {
$this->getPrinter()->write('help extended help' . PHP_EOL, 'HEADER'); $this->run();
$this->getPrinter()->write('help extended help' . PHP_EOL, 'ERROR');
$this->getPrinter()->write('help extended help' . PHP_EOL, 'INFO');
$this->getPrinter()->write('help extended help' . PHP_EOL, 'COMMENT');
$this->getPrinter()->write('help extended help' . PHP_EOL, 'NONE');
} }
/** /**
...@@ -51,11 +49,7 @@ class HelpTask extends AbstractTask ...@@ -51,11 +49,7 @@ class HelpTask extends AbstractTask
*/ */
public function basicHelp() public function basicHelp()
{ {
$this->getPrinter()->write('help basic help' . PHP_EOL, 'HEADER'); $this->run();
$this->getPrinter()->write('help basic help' . PHP_EOL, 'ERROR');
$this->getPrinter()->write('help basic help' . PHP_EOL, 'INFO');
$this->getPrinter()->write('help basic help' . PHP_EOL, 'COMMENT');
$this->getPrinter()->write('help basic help' . PHP_EOL, 'NONE');
} }
/** /**
...@@ -72,10 +66,22 @@ class HelpTask extends AbstractTask ...@@ -72,10 +66,22 @@ class HelpTask extends AbstractTask
*/ */
public function run() public function run()
{ {
$this->getPrinter()->write('help run' . PHP_EOL, 'HEADER'); // Switch between ALL available tasks and display the basic Help of each one
$this->getPrinter()->write('help run' . PHP_EOL, 'ERROR'); $availableTasks = $this->getAvailableTasks();
$this->getPrinter()->write('help run' . PHP_EOL, 'INFO');
$this->getPrinter()->write('help run' . PHP_EOL, 'COMMENT'); $helpTaskName = Inflector::classify(str_replace('-', '_', 'help'));
$this->getPrinter()->write('help run' . PHP_EOL, 'NONE'); unset($availableTasks[$helpTaskName]);
ksort($availableTasks);
foreach ($availableTasks as $taskName => $taskClass) {
$task = new $taskClass();
$task->setAvailableTasks($availableTasks);
$task->setPrinter($this->getPrinter());
$task->setArguments($this->getArguments());
$task->basicHelp();
}
} }
} }
\ No newline at end of file
...@@ -39,11 +39,12 @@ class VersionTask extends AbstractTask ...@@ -39,11 +39,12 @@ class VersionTask extends AbstractTask
*/ */
public function extendedHelp() public function extendedHelp()
{ {
$this->getPrinter()->write('version extended help' . PHP_EOL, 'HEADER'); $this->getPrinter()->writeln('version extended help.', 'INFO');
/*$this->getPrinter()->write('version extended help' . PHP_EOL, 'HEADER');
$this->getPrinter()->write('version extended help' . PHP_EOL, 'ERROR'); $this->getPrinter()->write('version extended help' . PHP_EOL, 'ERROR');
$this->getPrinter()->write('version extended help' . PHP_EOL, 'INFO'); $this->getPrinter()->write('version extended help' . PHP_EOL, 'INFO');
$this->getPrinter()->write('version extended help' . PHP_EOL, 'COMMENT'); $this->getPrinter()->write('version extended help' . PHP_EOL, 'COMMENT');
$this->getPrinter()->write('version extended help' . PHP_EOL, 'NONE'); $this->getPrinter()->write('version extended help' . PHP_EOL, 'NONE');*/
} }
/** /**
...@@ -51,11 +52,12 @@ class VersionTask extends AbstractTask ...@@ -51,11 +52,12 @@ class VersionTask extends AbstractTask
*/ */
public function basicHelp() public function basicHelp()
{ {
$this->getPrinter()->write('version basic help' . PHP_EOL, 'HEADER'); $this->getPrinter()->writeln('version extended help.', 'INFO');
/*$this->getPrinter()->write('version basic help' . PHP_EOL, 'HEADER');
$this->getPrinter()->write('version basic help' . PHP_EOL, 'ERROR'); $this->getPrinter()->write('version basic help' . PHP_EOL, 'ERROR');
$this->getPrinter()->write('version basic help' . PHP_EOL, 'INFO'); $this->getPrinter()->write('version basic help' . PHP_EOL, 'INFO');
$this->getPrinter()->write('version basic help' . PHP_EOL, 'COMMENT'); $this->getPrinter()->write('version basic help' . PHP_EOL, 'COMMENT');
$this->getPrinter()->write('version basic help' . PHP_EOL, 'NONE'); $this->getPrinter()->write('version basic help' . PHP_EOL, 'NONE');*/
} }
/** /**
...@@ -72,10 +74,11 @@ class VersionTask extends AbstractTask ...@@ -72,10 +74,11 @@ class VersionTask extends AbstractTask
*/ */
public function run() public function run()
{ {
$this->getPrinter()->write('version run' . PHP_EOL, 'HEADER'); $this->getPrinter()->writeln('version normal flow.', 'INFO');
/*$this->getPrinter()->write('version run' . PHP_EOL, 'HEADER');
$this->getPrinter()->write('version run' . PHP_EOL, 'ERROR'); $this->getPrinter()->write('version run' . PHP_EOL, 'ERROR');
$this->getPrinter()->write('version run' . PHP_EOL, 'INFO'); $this->getPrinter()->write('version run' . PHP_EOL, 'INFO');
$this->getPrinter()->write('version run' . PHP_EOL, 'COMMENT'); $this->getPrinter()->write('version run' . PHP_EOL, 'COMMENT');
$this->getPrinter()->write('version run' . PHP_EOL, 'NONE'); $this->getPrinter()->write('version run' . PHP_EOL, 'NONE');*/
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment