From a3c09d4cc2c159a3c4f29dc6e8e0e3c36a7a6586 Mon Sep 17 00:00:00 2001 From: jwage Date: Wed, 7 Oct 2009 23:39:34 +0000 Subject: [PATCH] [2.0] Adding better docs for some tasks --- lib/Doctrine/ORM/Tools/Cli.php | 4 +++- ...ConvertMappingTask.php => MappingTask.php} | 0 .../ORM/Tools/Cli/Tasks/SchemaToolTask.php | 22 ++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) rename lib/Doctrine/ORM/Tools/Cli/Tasks/{ConvertMappingTask.php => MappingTask.php} (100%) diff --git a/lib/Doctrine/ORM/Tools/Cli.php b/lib/Doctrine/ORM/Tools/Cli.php index 91965df0b..acc9b9008 100644 --- a/lib/Doctrine/ORM/Tools/Cli.php +++ b/lib/Doctrine/ORM/Tools/Cli.php @@ -153,7 +153,7 @@ class Cli $processedArgs = $this->_processArguments($args); try { - $this->_printer->writeln('Doctrine Command Line Interface', 'HEADER'); + $this->_printer->writeln('Doctrine Command Line Interface' . PHP_EOL, 'HEADER'); // Handle possible multiple tasks on a single command foreach($processedArgs as $taskData) { @@ -177,7 +177,9 @@ class Cli } else if ($this->_isTaskValid($task)) { $task->run(); } else { + $this->_printer->write(PHP_EOL); $task->basicHelp(); // Fallback of not-valid task arguments + $this->_printer->write(PHP_EOL); } } else { throw \Doctrine\Common\DoctrineException::taskDoesNotExist($taskName); diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertMappingTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/MappingTask.php similarity index 100% rename from lib/Doctrine/ORM/Tools/Cli/Tasks/ConvertMappingTask.php rename to lib/Doctrine/ORM/Tools/Cli/Tasks/MappingTask.php diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php index 02f15b36d..985018d23 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php +++ b/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php @@ -72,7 +72,11 @@ class SchemaToolTask extends AbstractTask ->writeln("\t\tInstead of try to apply generated SQLs into EntityManager, output them.") ->write(PHP_EOL) ->write('--class-dir=', 'OPT_ARG') - ->writeln("\tOptional class directory to fetch for Entities."); + ->writeln("\tOptional class directory to fetch for Entities.") + ->write(PHP_EOL) + ->write('--re-create', 'OPT_ARG') + ->writeln("\t\tRuns --drop then --create to re-create the database.") + ->write(PHP_EOL); } /** @@ -87,7 +91,8 @@ class SchemaToolTask extends AbstractTask { $printer->write('schema-tool', 'KEYWORD') ->write(' (--create | --drop | --update)', 'REQ_ARG') - ->writeln(' [--dump-sql] [--class-dir=]', 'OPT_ARG'); + ->write(' [--dump-sql] [--class-dir=]', 'OPT_ARG') + ->writeln(' [--re-create]', 'OPT_ARG'); } /** @@ -105,6 +110,12 @@ class SchemaToolTask extends AbstractTask if ( ! $this->_requireEntityManager()) { return false; } + + if (array_key_exists('re-create', $args)) { + $args['drop'] = true; + $args['create'] = true; + $this->setArguments($args); + } $isCreate = isset($args['create']); $isDrop = isset($args['drop']); @@ -114,6 +125,11 @@ class SchemaToolTask extends AbstractTask $printer->writeln("You can't use --update with --create or --drop", 'ERROR'); return false; } + + if ( ! ($isCreate || $isDrop || $isUpdate)) { + $printer->writeln('You must specify at a minimum one of the options (--create, --drop, --update, --re-create).', 'ERROR'); + return false; + } $metadataDriver = $this->_em->getConfiguration()->getMetadataDriverImpl(); if ($metadataDriver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) { @@ -135,7 +151,7 @@ class SchemaToolTask extends AbstractTask public function run() { $args = $this->getArguments(); - + $isCreate = isset($args['create']); $isDrop = isset($args['drop']); $isUpdate = isset($args['update']);