|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Command; |
|
4
|
|
|
|
|
5
|
|
|
use App\Service\ProblemService; |
|
6
|
|
|
use Symfony\Component\Console\Command\Command; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
11
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
|
12
|
|
|
|
|
13
|
|
|
class ProblemsGenerateCommand extends Command |
|
14
|
|
|
{ |
|
15
|
|
|
protected static $defaultName = 'problems:generate'; |
|
16
|
|
|
protected static $defaultDescription = 'Add a short description for your command'; |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** @var ProblemService */ |
|
20
|
|
|
private $problemService; |
|
21
|
|
|
|
|
22
|
|
|
function __construct(ProblemService $problemService) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->problemService = $problemService; |
|
25
|
|
|
parent::__construct(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
protected function configure() |
|
29
|
|
|
{ |
|
30
|
|
|
$this |
|
31
|
|
|
->setDescription(self::$defaultDescription) |
|
32
|
|
|
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description') |
|
33
|
|
|
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description') |
|
34
|
|
|
; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
38
|
|
|
{ |
|
39
|
|
|
$io = new SymfonyStyle($input, $output); |
|
40
|
|
|
$arg1 = $input->getArgument('arg1'); |
|
41
|
|
|
|
|
42
|
|
|
if ($arg1) { |
|
43
|
|
|
$io->note(sprintf('You passed an argument: %s', $arg1)); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if ($input->getOption('option1')) { |
|
47
|
|
|
// ... |
|
48
|
|
|
} |
|
49
|
|
|
$this->problemService->createProblemReport(); |
|
50
|
|
|
|
|
51
|
|
|
// $io->success('You have a new command! Now make it your own! Pass --help to see your options.'); |
|
52
|
|
|
|
|
53
|
|
|
return Command::SUCCESS; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|