Skip to content

Commit

Permalink
improv: ensure all commands that extend abscommand has company id option
Browse files Browse the repository at this point in the history
  • Loading branch information
beesaferoot committed Nov 23, 2024
1 parent 6fdbace commit d55acff
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/backend/app/Console/Commands/AbstractSharedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ abstract class AbstractSharedCommand extends Command

protected int $EXECUTION_TYPE = self::EXECUTE_FOR_ALL;


/**
* Configure the command
*/
protected function configure(): void
{
parent::configure();

$this->addOption(
'company-id',
null,
\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL,
'The ID of the company to run the command for. If not provided, runs for all companies.'
);
}


protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var DatabaseProxyManagerService $databaseProxyManagerService */
Expand Down Expand Up @@ -62,7 +79,7 @@ private function runForCompany(
InputInterface $input,
OutputInterface $output,
): void {
$this->info('Running '.$this->name.' for company ID : '.$companyId);
$this->info('Running ' . $this->name . ' for company ID : ' . $companyId);
$databaseProxyManagerService->runForCompany($companyId, function () use ($input, $output) {
parent::execute($input, $output);
});
Expand Down

0 comments on commit d55acff

Please sign in to comment.