1
0
mirror of synced 2025-01-18 14:31:40 +03:00

[2.0] Adding better docs for some tasks

This commit is contained in:
jwage 2009-10-07 23:39:34 +00:00
parent a7d4e1e466
commit a3c09d4cc2
3 changed files with 22 additions and 4 deletions

View File

@ -153,7 +153,7 @@ class Cli
$processedArgs = $this->_processArguments($args); $processedArgs = $this->_processArguments($args);
try { 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 // Handle possible multiple tasks on a single command
foreach($processedArgs as $taskData) { foreach($processedArgs as $taskData) {
@ -177,7 +177,9 @@ class Cli
} else if ($this->_isTaskValid($task)) { } else if ($this->_isTaskValid($task)) {
$task->run(); $task->run();
} else { } else {
$this->_printer->write(PHP_EOL);
$task->basicHelp(); // Fallback of not-valid task arguments $task->basicHelp(); // Fallback of not-valid task arguments
$this->_printer->write(PHP_EOL);
} }
} else { } else {
throw \Doctrine\Common\DoctrineException::taskDoesNotExist($taskName); throw \Doctrine\Common\DoctrineException::taskDoesNotExist($taskName);

View File

@ -72,7 +72,11 @@ class SchemaToolTask extends AbstractTask
->writeln("\t\tInstead of try to apply generated SQLs into EntityManager, output them.") ->writeln("\t\tInstead of try to apply generated SQLs into EntityManager, output them.")
->write(PHP_EOL) ->write(PHP_EOL)
->write('--class-dir=<path>', 'OPT_ARG') ->write('--class-dir=<path>', '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') $printer->write('schema-tool', 'KEYWORD')
->write(' (--create | --drop | --update)', 'REQ_ARG') ->write(' (--create | --drop | --update)', 'REQ_ARG')
->writeln(' [--dump-sql] [--class-dir=<path>]', 'OPT_ARG'); ->write(' [--dump-sql] [--class-dir=<path>]', 'OPT_ARG')
->writeln(' [--re-create]', 'OPT_ARG');
} }
/** /**
@ -106,6 +111,12 @@ class SchemaToolTask extends AbstractTask
return false; return false;
} }
if (array_key_exists('re-create', $args)) {
$args['drop'] = true;
$args['create'] = true;
$this->setArguments($args);
}
$isCreate = isset($args['create']); $isCreate = isset($args['create']);
$isDrop = isset($args['drop']); $isDrop = isset($args['drop']);
$isUpdate = isset($args['update']); $isUpdate = isset($args['update']);
@ -115,6 +126,11 @@ class SchemaToolTask extends AbstractTask
return false; 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(); $metadataDriver = $this->_em->getConfiguration()->getMetadataDriverImpl();
if ($metadataDriver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) { if ($metadataDriver instanceof \Doctrine\ORM\Mapping\Driver\AnnotationDriver) {
if ( ! isset($args['class-dir'])) { if ( ! isset($args['class-dir'])) {