PAT-251 Init new command to mass project deletion#77
PAT-251 Init new command to mass project deletion#77jirkasemmler wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new console command for bulk deletion of projects through the Manage API. The command allows administrators to delete multiple projects by providing comma-separated project IDs, with built-in safety features including dry-run mode by default and proper error handling.
Key changes:
- Added
DeleteProjectscommand class with validation and error handling - Integrated the new command into the CLI application
- Added comprehensive documentation for the new command
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Keboola/Console/Command/DeleteProjects.php | New command implementation for bulk project deletion with dry-run support |
| cli.php | Registered the new DeleteProjects command in the application |
| README.md | Added documentation for the new bulk delete projects command |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| $projectDetail = $client->getDeletedProject($projectInfo['id']); | ||
| if (!$projectDetail['isDeleted']) { | ||
| $output->writeln( | ||
| sprintf('<err>project "%s" deletion failed</err>', $projectDetail['id']) |
There was a problem hiding this comment.
The tag <err> should be <error> to match Symfony Console's standard error formatting tags.
| sprintf('<err>project "%s" deletion failed</err>', $projectDetail['id']) | |
| sprintf('<error>project "%s" deletion failed</error>', $projectDetail['id']) |
|
|
||
| $client = $this->createClient($apiUrl, $apiToken); | ||
|
|
||
| $projectIds = array_filter(explode(',', $projects), 'is_numeric'); |
There was a problem hiding this comment.
The filtering silently removes non-numeric values without informing the user. Consider validating the input and providing feedback about invalid project IDs to help users identify typos or formatting issues.
| $projectIds = array_filter(explode(',', $projects), 'is_numeric'); | |
| $projectIdStrings = array_map('trim', explode(',', $projects)); | |
| $invalidProjectIds = array_filter($projectIdStrings, function($id) { | |
| return !is_numeric($id); | |
| }); | |
| if (!empty($invalidProjectIds)) { | |
| $output->writeln('<error>Invalid project IDs detected: ' . implode(', ', $invalidProjectIds) . '</error>'); | |
| $output->writeln('Please check your input for typos or formatting issues. Only numeric project IDs are allowed.'); | |
| return 1; | |
| } | |
| $projectIds = array_map('intval', $projectIdStrings); |
| ->addOption('force', 'f', InputOption::VALUE_NONE, 'Will actually do the work, otherwise it\'s dry run'); | ||
| } | ||
|
|
||
| public function execute(InputInterface $input, OutputInterface $output): ?int |
There was a problem hiding this comment.
The return type should be int instead of ?int. Symfony Console commands should always return an integer exit code, and this method always returns 0.
| public function execute(InputInterface $input, OutputInterface $output): ?int | |
| public function execute(InputInterface $input, OutputInterface $output): int |
martinsifra
left a comment
There was a problem hiding this comment.
Koukni ještě na to, co radí Copilot..
Jira: PAT-251
adding a command for deleting bunch of projects