addOption('list-entities', null, InputOption::VALUE_NONE, 'List all entities') ->addOption('domain', null, InputOption::VALUE_REQUIRED, 'Filter entities by domain') ->addOption('entity-id', null, InputOption::VALUE_REQUIRED, 'Entity ID to interact with') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); if ($input->getOption('list-entities')) { return $this->listEntities($io); } $entityId = $input->getOption('entity-id'); if ($entityId === null) { $io->error('You must specify an entity ID using --entity-id option'); return Command::FAILURE; } return Command::SUCCESS; } private function listEntities(SymfonyStyle $io): int { $entities = $this->homeService->findAllEntities(); $rows = array_map( static fn (HomeEntityInterface $entity) => [ $entity->getId(), $entity->getName(), $entity->getState(), ], $entities, ); $io->table(['Entity ID', 'Name', 'State'], $rows); return Command::SUCCESS; } }