addArgument('table', InputArgument::REQUIRED, 'O nome da tabela');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$tableName = $input->getArgument('table');
$connection = Capsule::connection();
try {
$columns = $connection->select("SHOW COLUMNS FROM {$tableName}");
$output->writeln("Estrutura da tabela: {$tableName}");
$table = new Table($output);
$table->setHeaders(['Field', 'Type', 'Null', 'Key', 'Default', 'Extra']);
foreach ($columns as $column) {
$table->addRow([
$column->Field,
$column->Type,
$column->Null,
$column->Key,
$column->Default,
$column->Extra
]);
}
$table->render();
return Command::SUCCESS;
} catch (\Exception $e) {
$output->writeln("Tabela '{$tableName}' não encontrada ou erro na query.");
return Command::FAILURE;
}
}
}