1
0
Fork 0

Let users open the homepage of the current package by doing composer home without argument, fixes #6748

pull/6843/merge
Jordi Boggiano 2017-11-29 11:08:08 +01:00
parent 5130d02208
commit a1e292d84d
1 changed files with 8 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class HomeCommand extends BaseCommand
->setAliases(array('home')) ->setAliases(array('home'))
->setDescription('Opens the package\'s repository URL or homepage in your browser.') ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
->setDefinition(array( ->setDefinition(array(
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Package(s) to browse to.'), new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'), new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'), new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
)) ))
@ -61,7 +61,13 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
$return = 0; $return = 0;
foreach ($input->getArgument('packages') as $packageName) { $packages = $input->getArgument('packages');
if (!$packages) {
$io->writeError('No package specified, opening homepage for the root package');
$packages = [$this->getComposer()->getPackage()->getName()];
}
foreach ($packages as $packageName) {
$handled = false; $handled = false;
$packageExists = false; $packageExists = false;
foreach ($repos as $repo) { foreach ($repos as $repo) {