-
Notifications
You must be signed in to change notification settings - Fork 1
PAT-251 Init new command to mass project deletion #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
PAT-251 Init new command to mass project deletion #77
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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']) |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'); |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Koukni ještě na to, co radí Copilot..
Jira: PAT-251
adding a command for deleting bunch of projects