Commit 25be43c3 authored by romanb's avatar romanb

[2.0] Some small cleanups on new CLI code. Added basic CLI file 'doctrine'.

parent b3cb24aa
#!/usr/bin/env php
<?php
require __DIR__ . '/lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader->setBasePath('Doctrine', __DIR__ . '/lib');
$cli = new \Doctrine\ORM\Tools\Cli();
$cli->run($_SERVER['argv']);
......@@ -72,7 +72,7 @@ class Cli
public function __construct($printer = null)
{
//$this->_printer = new Printer\Normal();
$this->_printer = ($printer) ?: new Printer\AnsiColor();
$this->_printer = $printer ?: new Printer\AnsiColor();
// Include core tasks
$ns = 'Doctrine\ORM\Tools\Cli\Task';
......@@ -125,7 +125,7 @@ class Cli
$taskArguments['availableTasks'] = $this->_tasks;
// Check if task exists
if ($this->_tasks[$taskName] && class_exists($this->_tasks[$taskName], true)) {
if (isset($this->_tasks[$taskName]) && class_exists($this->_tasks[$taskName], true)) {
// Instantiate and execute the task
$task = new $this->_tasks[$taskName]();
$task->setPrinter($this->_printer);
......@@ -139,12 +139,12 @@ class Cli
$task->basicHelp(); // Fallback of not-valid task arguments
}
} else {
throw new Doctrine\Exception(
throw \Doctrine\Common\DoctrineException::updateMe(
'Unexistent task or attached task class does not exist.'
);
}
}
} catch (\Doctrine\Exception $e) {
} catch (\Doctrine\Common\DoctrineException $e) {
$this->_printer->write(
$taskName . ':' . $e->getMessage() . PHP_EOL, 'ERROR'
);
......
......@@ -21,8 +21,6 @@
namespace Doctrine\ORM\Tools\Cli;
use Doctrine\ORM\Tools\Cli\Style;
abstract class AbstractPrinter
{
protected $_stream;
......
......@@ -21,8 +21,6 @@
namespace Doctrine\ORM\Tools\Cli;
use Doctrine\ORM\Tools\Cli\AbstractPrinter;
abstract class AbstractTask
{
protected $_printer;
......
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