. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Cli\Commands; use Fisharebest\Webtrees\Services\TreeService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class TreeList extends Command { public function __construct(private readonly TreeService $tree_service) { parent::__construct(); } protected function configure(): void { $this ->setName(name: 'tree-list') ->setDescription(description: 'List trees'); } protected function execute(InputInterface $input, OutputInterface $output): int { $trees = $this->tree_service->all()->sort(callback: fn ($a, $b) => $a->id() <=> $b->id()); $table = new Table(output: $output); $table->setHeaders(headers: ['ID', 'Name', 'Title', 'Imported']); foreach ($trees as $tree) { $table->addRow(row: [ $tree->id(), $tree->name(), $tree->title(), $tree->getPreference(setting_name: 'imported') ? 'Yes' : 'No' ]); } $table->render(); return Command::SUCCESS; } }