1
0
Fork 0

add support for --no-progress, fixes #621

pull/1410/head
Galymzhan 2012-12-11 20:30:09 +06:00
parent aefe3a0b11
commit f59181d7d5
8 changed files with 57 additions and 4 deletions

View File

@ -60,6 +60,7 @@ class CreateProjectCommand extends Command
new InputOption('dev', null, InputOption::VALUE_NONE, 'Whether to install dependencies for development.'),
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Whether to disable custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deletion vcs folder.'),
))
->setHelp(<<<EOT
@ -102,11 +103,12 @@ EOT
$input->getOption('repository-url'),
$input->getOption('no-custom-installers'),
$input->getOption('no-scripts'),
$input->getOption('no-progress'),
$input->getOption('keep-vcs')
);
}
public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $keepVcs = false)
public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $noProgress = false, $keepVcs = false)
{
$config = Factory::createConfig();
@ -177,7 +179,8 @@ EOT
$dm = $this->createDownloadManager($io, $config);
$dm->setPreferSource($preferSource)
->setPreferDist($preferDist);
->setPreferDist($preferDist)
->setOutputProgress(!$noProgress);
$projectInstaller = new ProjectInstaller($directory, $dm);
$im = $this->createInstallationManager();

View File

@ -36,6 +36,7 @@ class InstallCommand extends Command
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump')
))
@ -55,6 +56,7 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$install = Installer::create($io, $composer);

View File

@ -37,6 +37,7 @@ class RequireCommand extends InitCommand
new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'),
))
->setHelp(<<<EOT
@ -92,6 +93,7 @@ EOT
// Update packages
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$install = Installer::create($io, $composer);

View File

@ -36,6 +36,7 @@ class UpdateCommand extends Command
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump')
))
@ -58,6 +59,7 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer();
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
$io = $this->getIO();
$install = Installer::create($io, $composer);

View File

@ -64,6 +64,22 @@ class DownloadManager
return $this;
}
/**
* Sets whether to output download progress information for all registered
* downloaders
*
* @param bool $outputProgress
* @return DownloadManager
*/
public function setOutputProgress($outputProgress)
{
foreach ($this->downloaders as $downloader) {
$downloader->setOutputProgress($outputProgress);
}
return $this;
}
/**
* Sets installer downloader for a specific installation type.
*

View File

@ -53,4 +53,12 @@ interface DownloaderInterface
* @param string $path download path
*/
public function remove(PackageInterface $package, $path);
/**
* Sets whether to output download progress information or not
*
* @param bool $outputProgress
* @return DownloaderInterface
*/
public function setOutputProgress($outputProgress);
}

View File

@ -36,6 +36,7 @@ class FileDownloader implements DownloaderInterface
protected $rfs;
protected $filesystem;
protected $cache;
protected $outputProgress = true;
/**
* Constructor.
@ -94,7 +95,7 @@ class FileDownloader implements DownloaderInterface
try {
try {
if (!$this->cache || !$this->cache->copyTo($this->getCacheKey($package), $fileName)) {
$this->rfs->copy($hostname, $processedUrl, $fileName);
$this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
if ($this->cache) {
$this->cache->copyFrom($this->getCacheKey($package), $fileName);
}
@ -108,7 +109,7 @@ class FileDownloader implements DownloaderInterface
) {
throw $e;
}
$this->rfs->copy($hostname, $processedUrl, $fileName);
$this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
} else {
throw $e;
}
@ -131,6 +132,16 @@ class FileDownloader implements DownloaderInterface
}
}
/**
* {@inheritDoc}
*/
public function setOutputProgress($outputProgress)
{
$this->outputProgress = $outputProgress;
return $this;
}
protected function clearCache(PackageInterface $package, $path)
{
if ($this->cache) {

View File

@ -132,6 +132,15 @@ abstract class VcsDownloader implements DownloaderInterface
}
}
/**
* Download progress information is not available for all VCS downloaders.
* {@inheritDoc}
*/
public function setOutputProgress($outputProgress)
{
return $this;
}
/**
* Prompt the user to check if changes should be stashed/removed or the operation aborted
*