app-info command fix
This commit is contained in:
@@ -34,6 +34,7 @@ use Espo\Core\{
|
||||
Utils\Module,
|
||||
Binding\EspoBindingLoader,
|
||||
Binding\Binding as BindingItem,
|
||||
Console\Params,
|
||||
};
|
||||
|
||||
class Binding
|
||||
@@ -45,7 +46,7 @@ class Binding
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
public function process(array $options, array $flagList) : ?string
|
||||
public function process(Params $params) : ?string
|
||||
{
|
||||
$result = '';
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Classes\AppInfo;
|
||||
use Espo\Core\{
|
||||
Container as ContainerService,
|
||||
Utils\Metadata,
|
||||
Console\Params,
|
||||
};
|
||||
|
||||
class Container
|
||||
@@ -45,9 +46,9 @@ class Container
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
public function process(array $options, array $flagList) : ?string
|
||||
public function process(Params $params) : ?string
|
||||
{
|
||||
$nameOnly = in_array('nameOnly', $flagList);
|
||||
$nameOnly = $params->hasFlag('nameOnly');
|
||||
|
||||
$result = '';
|
||||
|
||||
|
||||
@@ -33,11 +33,16 @@ use Espo\Core\{
|
||||
InjectableFactory,
|
||||
Utils\File\Manager as FileManager,
|
||||
Console\Command,
|
||||
Console\Params,
|
||||
Console\IO,
|
||||
};
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class AppInfo implements Command
|
||||
{
|
||||
protected $injectableFactory;
|
||||
|
||||
protected $fileManager;
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory, FileManager $fileManager)
|
||||
@@ -46,41 +51,49 @@ class AppInfo implements Command
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
public function run(array $options, array $flagList)
|
||||
public function run(Params $params, IO $io) : void
|
||||
{
|
||||
$fileList = $this->fileManager->getFileList('application/Espo/Classes/AppInfo');
|
||||
|
||||
$typeList = array_map(function ($item) {
|
||||
return lcfirst(substr($item, 0, -4));
|
||||
}, $fileList);
|
||||
$typeList = array_map(
|
||||
function ($item) {
|
||||
return lcfirst(substr($item, 0, -4));
|
||||
},
|
||||
$fileList
|
||||
);
|
||||
|
||||
foreach ($typeList as $type) {
|
||||
if (in_array($type, $flagList)) {
|
||||
$this->processType($type, $options, $flagList);
|
||||
if ($params->hasFlag($type)) {
|
||||
$this->processType($io, $type, $params);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($flagList)) {
|
||||
echo "No parameters specified.\n";
|
||||
if (count($params->getFlagList()) === 0) {
|
||||
$io->writeLine("No flag specified.");
|
||||
|
||||
$io->writeLine("");
|
||||
$io->writeLine("Available flags:");
|
||||
$io->writeLine(" --container");
|
||||
$io->writeLine(" --binding");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo "Bad parameters specified.\n";
|
||||
$io->writeLine("Not supported flag specified.");
|
||||
}
|
||||
|
||||
protected function processType(string $type, array $options, array $flagList)
|
||||
protected function processType(IO $io, string $type, Params $params) : void
|
||||
{
|
||||
$className = 'Espo\\Classes\\AppInfo\\' . ucfirst($type);
|
||||
|
||||
$obj = $this->injectableFactory->create($className);
|
||||
|
||||
$result = $obj->process($options, $flagList);
|
||||
$result = $obj->process($params);
|
||||
|
||||
if ($result) {
|
||||
echo $result;
|
||||
$io->write($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user