Add hints when the arg of show is not found, fixes #10493
parent
ee36c5e54a
commit
d124c13a42
|
@ -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());
|
||||||
|
|
Loading…
Reference in New Issue