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
$processedArgs = $this->_processArguments($args);
try {
$this->_printer->writeln(
'Doctrine Command Line Interface' . PHP_EOL, 'HEADER'
);
// Handle possible multiple tasks on a single command
foreach($processedArgs as $taskData) {
// Retrieve the task name and arguments
......@@ -182,7 +186,7 @@ class Cli
}
}
} catch (\Doctrine\Common\DoctrineException $e) {
$this->_printer->write(
$this->_printer->writeln(
$taskName . ':' . $e->getMessage() . PHP_EOL, 'ERROR'
);
}
......
......@@ -21,6 +21,8 @@
namespace Doctrine\ORM\Tools\Cli\Tasks;
use Doctrine\Common\Util\Inflector;
/**
* CLI Task to display available commands help
*
......@@ -39,11 +41,7 @@ class HelpTask extends AbstractTask
*/
public function extendedHelp()
{
$this->getPrinter()->write('help extended help' . PHP_EOL, 'HEADER');
$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');
$this->run();
}
/**
......@@ -51,11 +49,7 @@ class HelpTask extends AbstractTask
*/
public function basicHelp()
{
$this->getPrinter()->write('help basic help' . PHP_EOL, 'HEADER');
$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');
$this->run();
}
/**
......@@ -72,10 +66,22 @@ class HelpTask extends AbstractTask
*/
public function run()
{
$this->getPrinter()->write('help run' . PHP_EOL, 'HEADER');
$this->getPrinter()->write('help run' . PHP_EOL, 'ERROR');
$this->getPrinter()->write('help run' . PHP_EOL, 'INFO');
$this->getPrinter()->write('help run' . PHP_EOL, 'COMMENT');
$this->getPrinter()->write('help run' . PHP_EOL, 'NONE');
// Switch between ALL available tasks and display the basic Help of each one
$availableTasks = $this->getAvailableTasks();
$helpTaskName = Inflector::classify(str_replace('-', '_', 'help'));
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
*/
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, 'INFO');
$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
*/
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, 'INFO');
$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
*/
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, 'INFO');
$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