1
0
mirror of synced 2025-01-18 06:21: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);
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);

View File

@ -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=<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')
->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');
}
/**
@ -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']);