diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 1a3086ed8..8efd88725 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -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(<<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(); diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index d31dbdce7..0d8ffce2d 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -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); diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index b67d087d0..f75ec44db 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -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(<<getComposer(); + $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress')); $io = $this->getIO(); $install = Installer::create($io, $composer); diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 1cbc654b9..a6aa3a476 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -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); diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 42f822c00..e52212f76 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -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. * diff --git a/src/Composer/Downloader/DownloaderInterface.php b/src/Composer/Downloader/DownloaderInterface.php index 61dc35302..713bf36dc 100644 --- a/src/Composer/Downloader/DownloaderInterface.php +++ b/src/Composer/Downloader/DownloaderInterface.php @@ -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); } diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 752659040..437873492 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -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) { diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index ea40f0a81..55a189b7b 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -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 *