60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Dipper\Console\Commands;
|
|
|
|
use Dipper\Console\Finder;
|
|
use Dipper\Console\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Command\Command as SymfonyCommand;
|
|
|
|
/**
|
|
* @author HollyTeng <n.haoyuan@gmail.com>
|
|
*/
|
|
class JobListCommand extends SymfonyCommand
|
|
{
|
|
use Finder;
|
|
use Command;
|
|
|
|
/**
|
|
* The console command name.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $name = 'list:jobs';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'List the jobs.';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return bool|null
|
|
*/
|
|
public function fire()
|
|
{
|
|
foreach ($this->listJobs($this->argument('domain')) as $domain => $jobs) {
|
|
$this->comment("\n$domain\n");
|
|
$jobs = array_map(function ($job) {
|
|
return [$job->title, $job->domain->name, $job->file, $job->relativePath];
|
|
}, $jobs->all());
|
|
$this->table(['Job', 'Domain', 'File', 'Path'], $jobs);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the console command arguments.
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function getArguments()
|
|
{
|
|
return [
|
|
['domain', InputArgument::OPTIONAL, 'The domain to list the jobs of.'],
|
|
];
|
|
}
|
|
}
|