Skip to content

Conversation

@jirkasemmler
Copy link
Contributor

@jirkasemmler jirkasemmler commented Sep 11, 2025

Jira: PAT-251

adding a command for deleting bunch of projects

@jirkasemmler jirkasemmler requested review from a team, Copilot and martinsifra and removed request for a team September 12, 2025 06:20
Copy link

Copilot AI left a 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 DeleteProjects command 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'])
Copy link

Copilot AI Sep 12, 2025

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.

Suggested change
sprintf('<err>project "%s" deletion failed</err>', $projectDetail['id'])
sprintf('<error>project "%s" deletion failed</error>', $projectDetail['id'])

Copilot uses AI. Check for mistakes.

$client = $this->createClient($apiUrl, $apiToken);

$projectIds = array_filter(explode(',', $projects), 'is_numeric');
Copy link

Copilot AI Sep 12, 2025

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.

Suggested change
$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);

Copilot uses AI. Check for mistakes.
->addOption('force', 'f', InputOption::VALUE_NONE, 'Will actually do the work, otherwise it\'s dry run');
}

public function execute(InputInterface $input, OutputInterface $output): ?int
Copy link

Copilot AI Sep 12, 2025

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.

Suggested change
public function execute(InputInterface $input, OutputInterface $output): ?int
public function execute(InputInterface $input, OutputInterface $output): int

Copilot uses AI. Check for mistakes.
Copy link

@martinsifra martinsifra left a 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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants