Added option to show env and ports in find command
This commit is contained in:
@ -15,12 +15,17 @@ class FindCommand extends Command
|
||||
protected function configure()
|
||||
{
|
||||
$this->addArgument("service", InputArgument::OPTIONAL, "Search query");
|
||||
$this->addOption("environment", "E", InputOption::VALUE_NONE, "Show the environment for the services");
|
||||
$this->addOption("ports", "P", InputOption::VALUE_NONE, "Show the ports for the services");
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$serviceRegistry = $this->getServiceRegistry();
|
||||
|
||||
$printEnvs = $input->getOption("environment");
|
||||
$printPorts = $input->getOption("ports");
|
||||
|
||||
$services = $serviceRegistry->findAllServices();
|
||||
$query = $input->getArgument("service");
|
||||
|
||||
@ -37,6 +42,17 @@ class FindCommand extends Command
|
||||
$tags = "";
|
||||
}
|
||||
$output->writeln(sprintf(" <comment>%s</>: <info>%s</> <fg=cyan>%s</>", $service['name'], $service['description']??"?", $tags));
|
||||
if ($printEnvs) {
|
||||
foreach ($service['environment']??[] as $env=>$value) {
|
||||
$output->writeln(sprintf(" <fg=cyan>%s</>=<fg=magenta>%s</>", $env, $value));
|
||||
|
||||
}
|
||||
}
|
||||
if ($printPorts) {
|
||||
foreach ($service['ports']??[] as $port) {
|
||||
$output->writeln(sprintf(" Port: <fg=cyan>%s</> (<info>%s</>)", $port['port'], $port['info']??"Unknown"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
|
Reference in New Issue
Block a user