New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added global --working-dir option #1110

merged 2 commits into from Sep 15, 2012
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+19 −0
Diff settings


Just for now

@@ -93,15 +93,33 @@ public function doRun(InputInterface $input, OutputInterface $output)
$startTime = microtime(true);
$oldWorkingDir = getcwd();
$result = parent::doRun($input, $output);
if (isset($startTime)) {
$output->writeln('<info>Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MB), time: '.round(microtime(true) - $startTime, 2).'s');
return $result;
* @param InputInterface $input
* @throws \RuntimeException
private function switchWorkingDir(InputInterface $input)
$workingDir = $input->getParameterOption(array('--working-dir', '-d'), getcwd());
if (!is_dir($workingDir)) {
throw new \RuntimeException('Invalid working directoy specified.');
* @param bool $required
* @return \Composer\Composer
@@ -163,6 +181,7 @@ protected function getDefaultInputDefinition()
$definition = parent::getDefaultInputDefinition();
$definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
$definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
return $definition;
ProTip! Use n and p to navigate between commits in a pull request.