addArgument('name', InputArgument::REQUIRED, 'O nome do arquivo helper (ex: string_helpers)');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$name = $input->getArgument('name');
if (!str_ends_with($name, '.php')) {
$name .= '.php';
}
$directory = dirname(__DIR__, 2) . '/Helpers';
$filePath = $directory . '/' . $name;
if (file_exists($filePath)) {
$output->writeln("O helper '{$name}' já existe!");
return Command::FAILURE;
}
if (!is_dir($directory)) {
mkdir($directory, 0755, true);
}
$year = date('Y');
$template = <<writeln("Helper '{$name}' criado com sucesso em app/Helpers/");
$output->writeln("Lembre-se de incluir o arquivo no composer.json ou carregar manualmente.");
return Command::SUCCESS;
} else {
$output->writeln("Falha ao criar o arquivo do helper.");
return Command::FAILURE;
}
}
}