addArgument('name', InputArgument::REQUIRED, 'O novo nome da aplicação');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$newName = $input->getArgument('name');
$envFile = dirname(__DIR__, 3) . '/.env';
if (!file_exists($envFile)) {
$output->writeln('Arquivo .env não encontrado.');
return Command::FAILURE;
}
$content = file_get_contents($envFile);
$pattern = "/APP_NAME=(.*)/";
$replacement = "APP_NAME=\"{$newName}\"";
if (preg_match($pattern, $content)) {
$newContent = preg_replace($pattern, $replacement, $content);
} else {
$newContent = $content . "\nAPP_NAME=\"{$newName}\"";
}
if (file_put_contents($envFile, $newContent)) {
$output->writeln("Aplicação renomeada para '{$newName}' com sucesso!");
return Command::SUCCESS;
}
$output->writeln('Falha ao renomear a aplicação.');
return Command::FAILURE;
}
}