Added option to show env and ports in find command

This commit is contained in:
Chris 2022-09-28 13:36:54 +02:00
parent b21002bec2
commit 0506b1826e
3 changed files with 21 additions and 0 deletions

4
CHANGELOG.md Normal file
View File

@ -0,0 +1,4 @@
### 0.1.0
* Initial release

View File

@ -10,6 +10,7 @@
- [x] Add filtering to `find` command, to seach for tags or name - [x] Add filtering to `find` command, to seach for tags or name
- [ ] App port binding, i.e. phpmyadmin on 9000, phpcacheadmin on 9001 - [ ] App port binding, i.e. phpmyadmin on 9000, phpcacheadmin on 9001
- [ ] Make use of a `~/.serverenvs` to override envs for instances - [ ] Make use of a `~/.serverenvs` to override envs for instances
- [ ] Consider UDP?
## Examples ## Examples

View File

@ -15,12 +15,17 @@ class FindCommand extends Command
protected function configure() protected function configure()
{ {
$this->addArgument("service", InputArgument::OPTIONAL, "Search query"); $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) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$serviceRegistry = $this->getServiceRegistry(); $serviceRegistry = $this->getServiceRegistry();
$printEnvs = $input->getOption("environment");
$printPorts = $input->getOption("ports");
$services = $serviceRegistry->findAllServices(); $services = $serviceRegistry->findAllServices();
$query = $input->getArgument("service"); $query = $input->getArgument("service");
@ -37,6 +42,17 @@ class FindCommand extends Command
$tags = ""; $tags = "";
} }
$output->writeln(sprintf(" <comment>%s</>: <info>%s</> <fg=cyan>%s</>", $service['name'], $service['description']??"?", $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; return self::SUCCESS;