1
0
Fork 0

Add hints when the arg of show is not found, fixes #10493

pull/10517/head
Jordi Boggiano 2022-02-04 16:17:02 +01:00
parent ee36c5e54a
commit d124c13a42
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 13 additions and 8 deletions

View File

@ -247,16 +247,21 @@ EOT
if (empty($package)) { if (empty($package)) {
$options = $input->getOptions(); $options = $input->getOptions();
if (!isset($options['working-dir']) || !file_exists('composer.json')) { $hint = '';
if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) { if ($input->getOption('locked')) {
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.'); $hint .= ' in lock file';
} }
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found'); if (isset($options['working-dir'])) {
$hint .= ' in ' . $options['working-dir'] . '/composer.json';
}
if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
$hint .= ', try using --platform (-p) to show platform packages';
}
if (!$input->getOption('all')) {
$hint .= ', try using --all (-a) to show all available packages';
} }
$io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json'); throw new \InvalidArgumentException('Package "' . $packageFilter . '" not found'.$hint.'.');
return 1;
} }
} else { } else {
$versions = array($package->getPrettyVersion() => $package->getVersion()); $versions = array($package->getPrettyVersion() => $package->getVersion());