1
0
mirror of synced 2025-02-20 14:13:15 +03:00

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

This commit is contained in:
romanb 2009-08-24 10:18:10 +00:00
parent b3cb24aa8f
commit 25be43c314
4 changed files with 14 additions and 8 deletions

10
doctrine Executable file
View File

@ -0,0 +1,10 @@
#!/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']);

View File

@ -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'
);

View File

@ -21,8 +21,6 @@
namespace Doctrine\ORM\Tools\Cli;
use Doctrine\ORM\Tools\Cli\Style;
abstract class AbstractPrinter
{
protected $_stream;

View File

@ -21,8 +21,6 @@
namespace Doctrine\ORM\Tools\Cli;
use Doctrine\ORM\Tools\Cli\AbstractPrinter;
abstract class AbstractTask
{
protected $_printer;