Completed
Pull Request — master (#24551)
by Thomas
19:32 queued 48s
created

Status::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace OC\Core\Command\Background\Queue;
4
5
use OCP\BackgroundJob\IJob;
6
use OCP\BackgroundJob\IJobList;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Helper\Table;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class Status extends Command {
13
14
	/** @var \OCP\BackgroundJob\IJobList */
15
	private $jobList;
16
17
	public function __construct(IJobList $jobList) {
18
		$this->jobList = $jobList;
19
		parent::__construct();
20
	}
21
22
	protected function configure() {
23
		$this
24
			->setName('background:queue:status')
25
			->setDescription('List queue status');
26
	}
27
28
	/**
29
	* @param InputInterface $input
30
	* @param OutputInterface $output
31
	 * @return void
32
	*/
33
	protected function execute(InputInterface $input, OutputInterface $output) {
34
		$t = new Table($output);
35
		$t->setHeaders(['Id', 'Job', 'Last run', 'Arguments']);
36
		$this->jobList->listJobs(function (IJob $job) use ($t) {
37
			$t->addRow([$job->getId(), \get_class($job), \date('c', $job->getLastRun()), $job->getArgument()]);
38
		});
39
		$t->render();
40
	}
41
}
42