protected function execute(InputInterface $input, OutputInterface $output) { $vagrant = new Vagrant(); $hostList = $this->getHostList($input, $output); if ($hostList === null) { $vagrant->commandHalt(); } else { $count = count($hostList); # handle all boxes that match the inputStr foreach ($hostList as $host) { /** @var \App\Service\Vagrant\Host $host */ $output->writeln(sprintf("<fg=yellow>Halting:</> %s <fg=blue>%s</>", $host->getData("name"), $host->getData("dir"))); $vagrant->commandHalt($host->getData("id")); } # print success-message if ($count) { $output->writeln(sprintf("<fg=green>Done:</> Halted <fg=blue>%s</> %s", $count, $count > 1 ? 'boxes' : "box")); } } }