1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

fluent api for installer options

This commit is contained in:
digitalkaoz 2012-03-10 18:08:36 +01:00
parent edf93f1fcc
commit 673dd6312b
4 changed files with 142 additions and 49 deletions

View file

@ -120,7 +120,9 @@ EOT
$composer = Factory::create($io);
$installer = Installer::create($io, $composer);
$installer->run($preferSource);
$installer
->setPreferSource($preferSource)
->run();
}
protected function createDownloadManager(IOInterface $io)

View file

@ -32,7 +32,7 @@ class InstallCommand extends Command
->setDefinition(array(
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
new InputOption('no-install-recommends', null, InputOption::VALUE_NONE, 'Do not install recommended packages (ignored when installing from an existing lock file).'),
new InputOption('install-recommends', null, InputOption::VALUE_NONE, 'Also install recommended packages (ignored when installing from an existing lock file).'),
new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages (ignored when installing from an existing lock file).'),
))
->setHelp(<<<EOT
@ -53,12 +53,14 @@ EOT
$io = $this->getApplication()->getIO();
$install = Installer::create($io, $composer);
return $install->run(
(Boolean) $input->getOption('prefer-source'),
(Boolean) $input->getOption('dry-run'),
(Boolean) $input->getOption('verbose'),
(Boolean) $input->getOption('no-install-recommends'),
(Boolean) $input->getOption('install-suggests')
);
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source'))
->setInstallRecommends($input->getOption('install-recommends'))
->setInstallSuggests($input->getOption('install-suggests'))
;
return $install->run();
}
}

View file

@ -31,7 +31,7 @@ class UpdateCommand extends Command
->setDefinition(array(
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
new InputOption('no-install-recommends', null, InputOption::VALUE_NONE, 'Do not install recommended packages.'),
new InputOption('install-recommends', null, InputOption::VALUE_NONE, 'Also install recommended packages.'),
new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages.'),
))
->setHelp(<<<EOT
@ -53,13 +53,15 @@ EOT
$eventDispatcher = new EventDispatcher($composer, $io);
$install = Installer::create($io, $composer, $eventDispatcher);
return $install->run(
(Boolean)$input->getOption('prefer-source'),
(Boolean)$input->getOption('dry-run'),
(Boolean)$input->getOption('verbose'),
(Boolean)$input->getOption('no-install-recommends'),
(Boolean)$input->getOption('install-suggests'),
true
);
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source'))
->setInstallRecommends($input->getOption('install-recommends'))
->setInstallSuggests($input->getOption('install-suggests'))
->setUpdate(true)
;
return $install->run();
}
}