Skip to content

Commit

Permalink
[2.0][DDC-274] Fixing Coding Standards for CLI tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermeblanco committed Mar 24, 2010
1 parent 50c4e50 commit b216798
Show file tree
Hide file tree
Showing 37 changed files with 155 additions and 155 deletions.
6 changes: 3 additions & 3 deletions bin/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
require $configFile;

foreach ($GLOBALS as $configCandidate) {
if ($configCandidate instanceof \Doctrine\Common\Cli\Configuration) {
if ($configCandidate instanceof \Doctrine\Common\CLI\Configuration) {
$configuration = $configCandidate;
break;
}
}
}

$configuration = ($configuration) ?: new \Doctrine\Common\Cli\Configuration();
$configuration = ($configuration) ?: new \Doctrine\Common\CLI\Configuration();

$cli = new \Doctrine\Common\Cli\CliController($configuration);
$cli = new \Doctrine\Common\CLI\CLIController($configuration);
$cli->run($_SERVER['argv']);
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

use Doctrine\Common\Util\Inflector;

Expand Down Expand Up @@ -73,7 +73,7 @@ public function addNamespace($name)
$name = self::formatName($name);

if ($this->hasNamespace($name)) {
throw CliException::cannotOverrideNamespace($name);
throw CLIException::cannotOverrideNamespace($name);
}

return $this->overrideNamespace($name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

/**
* Generic CLI Controller of Tasks execution
*
* To include a new Task support, create a task:
*
* [php]
* class MyProject\Tools\Cli\Tasks\MyTask extends Doctrine\ORM\Tools\Cli\Tasks\AbstractTask
* class MyProject\Tools\CLI\Tasks\MyTask extends Doctrine\ORM\Tools\CLI\Tasks\AbstractTask
* {
* public function run();
* public function basicHelp();
Expand All @@ -38,9 +38,9 @@
* And then, load the namespace assoaicated an include the support to it in your command-line script:
*
* [php]
* $cli = new Doctrine\Common\Cli\CliController();
* $cli = new Doctrine\Common\CLI\CLIController();
* $cliNS = $cli->getNamespace('custom');
* $cliNS->addTask('myTask', 'MyProject\Tools\Cli\Tasks\MyTask');
* $cliNS->addTask('myTask', 'MyProject\Tools\CLI\Tasks\MyTask');
*
* To execute, just type any classify-able name:
*
Expand All @@ -55,7 +55,7 @@
* @author Jonathan Wage <[email protected]>
* @author Roman Borschel <[email protected]>
*/
class CliController extends AbstractNamespace
class CLIController extends AbstractNamespace
{
/**
* The CLI processor of tasks
Expand All @@ -69,12 +69,12 @@ public function __construct(Configuration $config, Printers\AbstractPrinter $pri
$this->setConfiguration($config);

// Include core namespaces of tasks
$ns = 'Doctrine\Common\Cli\Tasks';
$ns = 'Doctrine\Common\CLI\Tasks';
$this->addNamespace('Core')
->addTask('help', $ns . '\HelpTask')
->addTask('version', $ns . '\VersionTask');

$ns = 'Doctrine\ORM\Tools\Cli\Tasks';
$ns = 'Doctrine\ORM\Tools\CLI\Tasks';
$this->addNamespace('Orm')
->addTask('clear-cache', $ns . '\ClearCacheTask')
->addTask('convert-mapping', $ns . '\ConvertMappingTask')
Expand All @@ -87,7 +87,7 @@ public function __construct(Configuration $config, Printers\AbstractPrinter $pri
->addTask('generate-entities', $ns . '\GenerateEntitiesTask')
->addTask('generate-repositories', $ns . '\GenerateRepositoriesTask');

$ns = 'Doctrine\DBAL\Tools\Cli\Tasks';
$ns = 'Doctrine\DBAL\Tools\CLI\Tasks';
$this->addNamespace('Dbal')
->addTask('run-sql', $ns . '\RunSqlTask')
->addTask('version', $ns . '\VersionTask');
Expand All @@ -98,12 +98,12 @@ public function __construct(Configuration $config, Printers\AbstractPrinter $pri
* Example of inclusion support to a single task:
*
* [php]
* $cli->addTask('my-custom-task', 'MyProject\Cli\Tasks\MyCustomTask');
* $cli->addTask('my-custom-task', 'MyProject\CLI\Tasks\MyCustomTask');
*
* @param string $name CLI Task name
* @param string $class CLI Task class (FQCN - Fully Qualified Class Name)
*
* @return CliController This object instance
* @return CLIController This object instance
*/
public function addTask($name, $class)
{
Expand Down Expand Up @@ -294,7 +294,7 @@ private function _retrieveTaskNamespace($namespacePath)

// If the given namespace returned "null", throw exception
if ($taskNamespace === null) {
throw CliException::namespaceDoesNotExist($namespaceName, $currentNamespacePath);
throw CLIException::namespaceDoesNotExist($namespaceName, $currentNamespacePath);
}

$currentNamespacePath = (( ! empty($currentNamespacePath)) ? ':' : '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

/**
* CLI Exception class
Expand All @@ -33,7 +33,7 @@
* @author Jonathan Wage <[email protected]>
* @author Roman Borschel <[email protected]>
*/
class CliException extends \Doctrine\Common\CommonException
class CLIException extends \Exception
{
public static function namespaceDoesNotExist($namespaceName, $namespacePath = '')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

/**
* CLI Configuration class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

/**
* CLI Option definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

use Doctrine\Common\Cli\Printers\AbstractPrinter;
use Doctrine\Common\CLI\Printers\AbstractPrinter;

/**
* CLI Option Group definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli\Printers;
namespace Doctrine\Common\CLI\Printers;

use Doctrine\Common\Cli\Style;
use Doctrine\Common\CLI\Style;

/**
* CLI Output Printer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli\Printers;
namespace Doctrine\Common\CLI\Printers;

use Doctrine\Common\Cli\Style;
use Doctrine\Common\CLI\Style;

/**
* CLI Output Printer for ANSI Color terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli\Printers;
namespace Doctrine\Common\CLI\Printers;

use Doctrine\Common\Cli\Style;
use Doctrine\Common\CLI\Style;

/**
* CLI Output Printer for Normal terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

/**
* CLI Output Style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

use Doctrine\Common\Cli\Printers\AbstractPrinter,
Doctrine\Common\Cli\OptionGroup,
Doctrine\Common\Cli\Option;
use Doctrine\Common\CLI\Printers\AbstractPrinter,
Doctrine\Common\CLI\OptionGroup,
Doctrine\Common\CLI\Option;

/**
* CLI Task documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli;
namespace Doctrine\Common\CLI;

/**
* CLI Namespace class
Expand Down Expand Up @@ -81,7 +81,7 @@ public function getTask($name)
return new $taskClass($this);
}

throw CliException::taskDoesNotExist($name, $this->getFullName());
throw CLIException::taskDoesNotExist($name, $this->getFullName());
}

/**
Expand Down Expand Up @@ -129,7 +129,7 @@ public function addTask($name, $class)
$name = self::formatName($name);

if ($this->hasTask($name)) {
throw CliException::cannotOverrideTask($name);
throw CLIException::cannotOverrideTask($name);
}

return $this->overrideTask($name, $class);
Expand Down Expand Up @@ -228,7 +228,7 @@ public function runTask($name, $arguments = array())
} else if ($task->validate()) {
$task->run();
}
} catch (CliException $e) {
} catch (CLIException $e) {
$message = $this->getFullName() . ':' . $name . ' => ' . $e->getMessage();
$printer = $this->getPrinter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli\Tasks;
namespace Doctrine\Common\CLI\Tasks;

use Doctrine\Common\Cli\AbstractNamespace,
Doctrine\Common\Cli\TaskDocumentation;
use Doctrine\Common\CLI\AbstractNamespace,
Doctrine\Common\CLI\TaskDocumentation;

/**
* Base class for CLI Tasks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli\Tasks;
namespace Doctrine\Common\CLI\Tasks;

use Doctrine\Common\Cli\CliException;
use Doctrine\Common\CLI\CLIException;

/**
* CLI Task to display available commands help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\Common\Cli\Tasks;
namespace Doctrine\Common\CLI\Tasks;

use Doctrine\Common\Version;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\DBAL\Tools\Cli\Tasks;
namespace Doctrine\DBAL\Tools\CLI\Tasks;

use Doctrine\Common\Cli\Tasks\AbstractTask,
Doctrine\Common\Cli\CliException,
use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\CLI\CLIException,
Doctrine\Common\Util\Debug,
Doctrine\Common\Cli\Option,
Doctrine\Common\Cli\OptionGroup;
Doctrine\Common\CLI\Option,
Doctrine\Common\CLI\OptionGroup;

/**
* Task for executing arbitrary SQL that can come from a file or directly from
Expand Down Expand Up @@ -78,13 +78,13 @@ public function validate()
$em = $this->getConfiguration()->getAttribute('em');

if ($em === null) {
throw new CliException(
throw new CLIException(
"Attribute 'em' of CLI Configuration is not defined or it is not a valid EntityManager."
);
}

if ( ! (isset($arguments['sql']) ^ isset($arguments['file']))) {
throw new CliException('One of --sql or --file required, and only one.');
throw new CLIException('One of --sql or --file required, and only one.');
}

return true;
Expand All @@ -107,9 +107,9 @@ public function run()

foreach ($fileNames as $fileName) {
if ( ! file_exists($fileName)) {
throw new CliException(sprintf('The SQL file [%s] does not exist.', $fileName));
throw new CLIException(sprintf('The SQL file [%s] does not exist.', $fileName));
} else if ( ! is_readable($fileName)) {
throw new CliException(sprintf('The SQL file [%s] does not have read permissions.', $fileName));
throw new CLIException(sprintf('The SQL file [%s] does not have read permissions.', $fileName));
}

$printer->write('Processing file [' . $fileName . ']... ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\DBAL\Tools\Cli\Tasks;
namespace Doctrine\DBAL\Tools\CLI\Tasks;

use Doctrine\Common\Cli\Tasks\AbstractTask,
use Doctrine\Common\CLI\Tasks\AbstractTask,
Doctrine\Common\Version;

/**
Expand Down
Loading

0 comments on commit b216798

Please sign in to comment.