Permalink
Browse files

[Command] Fixed commands

  • Loading branch information...
1 parent 5a16c9a commit d11f304e1becfd8f90f92d9ee0a94be79798a341 @willdurand willdurand committed Dec 21, 2011
@@ -32,10 +32,9 @@
protected function configure()
{
$this
- ->setDefinition(array(
- new InputOption('input-dir', null, InputOption::VALUE_REQUIRED, 'The input directory', self::DEFAULT_INPUT_DIRECTORY),
- new InputOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform', self::DEFAULT_PLATFORM),
- ));
+ ->addOption('input-dir', null, InputOption::VALUE_REQUIRED, 'The input directory', self::DEFAULT_INPUT_DIRECTORY)
+ ->addOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform', self::DEFAULT_PLATFORM)
+ ;
}
protected function getBuildProperties($file)
@@ -2,7 +2,6 @@
namespace Propel\Generator\Command;
-use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -17,7 +16,7 @@
* @author Florian Klein <florian.klein@free.fr>
* @author William Durand <william.durand1@gmail.com>
*/
-class ModelBuild extends Command
+class ModelBuild extends AbstractCommand
{
const DEFAULT_OUTPUT_DIRECTORY = 'generated-classes';
@@ -48,10 +47,10 @@ class ModelBuild extends Command
*/
protected function configure()
{
+ parent::configure();
+
$this
- ->setDefinition(array(
- new InputOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY),
- ))
+ ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY)
->addOption('peer-class', null, InputOption::VALUE_REQUIRED,
'The peer class generator name', self::DEFAULT_PEER_BUILDER)
->addOption('peer-stub-class', null, InputOption::VALUE_REQUIRED,
@@ -86,8 +85,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- parent::configure();
-
$generatorConfig = new GeneratorConfig(array(
'propel.platform.class' => $input->getOption('platform'),
'propel.builder.peer.class' => $input->getOption('peer-class'),
@@ -109,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$manager = new ModelManager();
$manager->setGeneratorConfig($generatorConfig);
- $manager->setSchemas($this->getSchemas());
+ $manager->setSchemas($this->getSchemas($input));
$manager->setLoggerClosure(function($message) use ($input, $output) {
if ($input->getOption('verbose')) {
$output->writeln($message);
@@ -38,16 +38,13 @@ protected function configure()
parent::configure();
$this
- ->setDefinition(array(
- new InputOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY),
- new InputOption('validate', null, InputOption::VALUE_NONE, ''),
- new InputOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform', self::DEFAULT_PLATFORM),
- new InputOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name for RDBMS supporting them', ''),
- new InputOption('encoding', null, InputOption::VALUE_REQUIRED, 'The encoding to use for the database', ''),
- new InputOption('table-prefix', null, InputOption::VALUE_REQUIRED, 'Add a prefix to all the table names in the database', ''),
- // MySQL specific
- new InputOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)', self::DEFAULT_MYSQL_ENGINE),
- ))
+ ->addOption('output-dir', null, InputOption::VALUE_REQUIRED, 'The output directory', self::DEFAULT_OUTPUT_DIRECTORY)
+ ->addOption('validate', null, InputOption::VALUE_NONE, '')
+ ->addOption('schema-name', null, InputOption::VALUE_REQUIRED, 'The schema name for RDBMS supporting them', '')
+ ->addOption('encoding', null, InputOption::VALUE_REQUIRED, 'The encoding to use for the database', '')
+ ->addOption('table-prefix', null, InputOption::VALUE_REQUIRED, 'Add a prefix to all the table names in the database', '')
+ // MySQL specific
+ ->addOption('mysql-engine', null, InputOption::VALUE_REQUIRED, 'MySQL engine (MyISAM, InnoDB, ...)', self::DEFAULT_MYSQL_ENGINE)
->setName('sql:build')
->setDescription('Build SQL files')
;
@@ -73,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$manager = new SqlManager();
$manager->setValidate($input->getOption('validate'));
$manager->setGeneratorConfig($generatorConfig);
- $manager->setSchemas($this->getSchemas());
+ $manager->setSchemas($this->getSchemas($input));
$manager->setLoggerClosure(function($message) use ($input, $output) {
if ($input->getOption('verbose')) {
$output->writeln($message);
@@ -141,7 +141,7 @@ protected function buildFixtures($fixturesDir, InputInterface $input, OutputInte
'--input-dir' => '.',
'--output-dir' => 'build/sql/',
'--platform' => ucfirst($input->getOption('vendor')) . 'Platform',
- '--verbose' => $input->getOption('vendor'),
+ '--verbose' => $input->getOption('verbose'),
));
$command = $this->getApplication()->find('sql:build');
@@ -152,7 +152,7 @@ protected function buildFixtures($fixturesDir, InputInterface $input, OutputInte
'--input-dir' => '.',
'--output-dir' => 'build/classes/',
'--platform' => ucfirst($input->getOption('vendor')) . 'Platform',
- '--verbose' => $input->getOption('vendor'),
+ '--verbose' => $input->getOption('verbose'),
));
$command = $this->getApplication()->find('model:build');

0 comments on commit d11f304

Please sign in to comment.