Skip to content

Commit

Permalink
Fix Command::execute() to return int
Browse files Browse the repository at this point in the history
  • Loading branch information
rybakit committed Jun 23, 2021
1 parent d3669b6 commit f8e3d0d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Console/Command/KickCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function configure(): void
;
}

protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$queue = $this->createConfigFactory($input, $output)->createQueue();
$count = $input->getArgument('count');
Expand All @@ -31,5 +31,7 @@ protected function execute(InputInterface $input, OutputInterface $output): void
$affected,
$queue->getName()
));

return 0;
}
}
4 changes: 3 additions & 1 deletion src/Console/Command/PutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function configure(): void
;
}

protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$json = $input->getArgument('json-data');
$data = json_decode($json, true);
Expand All @@ -37,5 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output): void
$queue->getName(),
$task->getId()
));

return 0;
}
}
4 changes: 3 additions & 1 deletion src/Console/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function configure(): void
;
}

protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$configFactory = $this->createConfigFactory($input, $output);

Expand All @@ -40,5 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): void

$runner = $configFactory->createRunner();
$runner->run($input->getOption('idle-timeout'));

return 0;
}
}
4 changes: 3 additions & 1 deletion src/Console/Command/StatsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ protected function configure(): void
;
}

protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$queue = $this->createConfigFactory($input, $output)->createQueue();
$stats = $queue->stats();

$output->writeln(sprintf('Queue: <options=bold>%s</>', $queue->getName()));
$output->writeln('Tasks: '.self::buildLine($stats['tasks']));
$output->writeln('Calls: '.self::buildLine($stats['calls']));

return 0;
}

private static function buildLine(array $stats): string
Expand Down
4 changes: 3 additions & 1 deletion src/Console/Command/TruncateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ protected function configure(): void
;
}

protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$queue = $this->createConfigFactory($input, $output)->createQueue();
$queue->truncate();

$output->writeln(sprintf('<info>%s</info> was successfully truncated.', $queue->getName()));

return 0;
}
}

0 comments on commit f8e3d0d

Please sign in to comment.