|
4 | 4 | * EPV :: The phpBB Forum Extension Pre Validator. |
5 | 5 | * |
6 | 6 | * @copyright (c) 2014 phpBB Limited <https://www.phpbb.com> |
7 | | - * @license GNU General Public License, version 2 (GPL-2.0) |
| 7 | + * @license GNU General Public License, version 2 (GPL-2.0) |
8 | 8 | * |
9 | 9 | */ |
10 | 10 | namespace Phpbb\Epv\Command; |
11 | 11 |
|
12 | 12 | use Phpbb\Epv\Output\Output; |
| 13 | +use Phpbb\Epv\Output\OutputFormatter; |
13 | 14 | use Phpbb\Epv\Tests\Exception\TestException; |
14 | 15 | use Phpbb\Epv\Tests\TestStartup; |
15 | | -use Phpbb\Epv\Output\OutputFormatter; |
16 | 16 | use Symfony\Component\Console\Command\Command; |
17 | 17 | use Symfony\Component\Console\Input\InputArgument; |
18 | 18 | use Symfony\Component\Console\Input\InputInterface; |
19 | 19 | use Symfony\Component\Console\Input\InputOption; |
20 | 20 | use Symfony\Component\Console\Output\OutputInterface; |
21 | | -use Symfony\Component\Console\Tests\Input\InputOptionTest; |
22 | 21 |
|
23 | 22 |
|
24 | | -class ValidateCommand extends Command{ |
| 23 | +class ValidateCommand extends Command |
| 24 | +{ |
25 | 25 |
|
26 | | - protected function configure() |
27 | | - { |
28 | | - $this |
29 | | - ->setName('run') |
30 | | - ->setDescription('Run the Extension Pre Validator on your extension.') |
31 | | - //->addArgument('dir', InputArgument::OPTIONAL, 'The directory the extension is in.') |
32 | | - //->addArgument('git', InputArgument::OPTIONAL, 'A git repository with the extension.') |
33 | | - ->addOption('dir', null, InputOption::VALUE_OPTIONAL, 'The directory the extension is in.') |
34 | | - ->addOption('git', null, InputOption::VALUE_OPTIONAL, 'A git repository with the extension.') |
35 | | - ->addOption('github', null, InputOption::VALUE_OPTIONAL, 'Shortname (like phpbb/phpbb) to github with the extension.') |
36 | | - ->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'A branch for the git repo') |
| 26 | + protected function configure() |
| 27 | + { |
| 28 | + $this |
| 29 | + ->setName('run') |
| 30 | + ->setDescription('Run the Extension Pre Validator on your extension.') |
| 31 | + //->addArgument('dir', InputArgument::OPTIONAL, 'The directory the extension is in.') |
| 32 | + //->addArgument('git', InputArgument::OPTIONAL, 'A git repository with the extension.') |
| 33 | + ->addOption('dir', null, InputOption::VALUE_OPTIONAL, 'The directory the extension is in.') |
| 34 | + ->addOption('git', null, InputOption::VALUE_OPTIONAL, 'A git repository with the extension.') |
| 35 | + ->addOption('github', null, InputOption::VALUE_OPTIONAL, 'Shortname (like phpbb/phpbb) to github with the extension.') |
| 36 | + ->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'A branch for the git repo') |
| 37 | + ->addOption('debug', null, InputOption::VALUE_NONE, "Run in debug"); |
| 38 | + } |
37 | 39 |
|
38 | | - ->addOption('debug', null, InputOption::VALUE_NONE, "Run in debug") |
| 40 | + protected function execute(InputInterface $input, OutputInterface $output) |
| 41 | + { |
| 42 | + $dir = $input->getOption("dir"); |
| 43 | + $git = $input->getOption('git'); |
| 44 | + $github = $input->getOption('github'); |
| 45 | + $branch = $input->getOption('branch'); |
| 46 | + $type = null; |
| 47 | + $loc = null; |
39 | 48 |
|
40 | | - ; |
41 | | - } |
42 | | - protected function execute(InputInterface $input, OutputInterface $output) |
43 | | - { |
44 | | - $dir = $input->getOption("dir"); |
45 | | - $git = $input->getOption('git'); |
46 | | - $github = $input->getOption('github'); |
47 | | - $branch = $input->getOption('branch'); |
48 | | - $type = null; |
49 | | - $loc = null; |
| 49 | + if (!empty($github)) |
| 50 | + { |
| 51 | + $type = TestStartup::TYPE_GITHUB; |
| 52 | + $loc = $github; |
| 53 | + } |
| 54 | + else if (!empty($git)) |
| 55 | + { |
| 56 | + $type = TestStartup::TYPE_GIT; |
| 57 | + $loc = $git; |
| 58 | + } |
| 59 | + else if (!empty($dir)) |
| 60 | + { |
| 61 | + $type = TestStartup::TYPE_DIRECTORY; |
| 62 | + $loc = $dir; |
| 63 | + } |
| 64 | + else |
| 65 | + { |
| 66 | + throw new TestException("Or the git or the dir parameter are required"); |
| 67 | + } |
50 | 68 |
|
51 | | - if (!empty($github)) |
52 | | - { |
53 | | - $type = TestStartup::TYPE_GITHUB; |
54 | | - $loc = $github; |
55 | | - } |
56 | | - else if (!empty($git)) |
57 | | - { |
58 | | - $type = TestStartup::TYPE_GIT; |
59 | | - $loc = $git; |
60 | | - } |
61 | | - else if (!empty($dir)) |
62 | | - { |
63 | | - $type = TestStartup::TYPE_DIRECTORY; |
64 | | - $loc = $dir; |
65 | | - } |
66 | | - else |
67 | | - { |
68 | | - throw new TestException("Or the git or the dir parameter are required"); |
69 | | - } |
| 69 | + $debug = $input->getOption("debug"); |
70 | 70 |
|
71 | | - $debug = $input->getOption("debug"); |
| 71 | + $output = new Output($output, $debug); |
| 72 | + $output->setFormatter(new OutputFormatter(true)); |
72 | 73 |
|
73 | | - $output = new Output($output, $debug); |
74 | | - $output->setFormatter(new OutputFormatter(true)); |
| 74 | + $test = new TestStartup($output, $type, $loc, $debug, $branch); |
75 | 75 |
|
76 | | - $test = new TestStartup($output, $type, $loc, $debug, $branch); |
| 76 | + if ($output->getFatalCount() > 0) |
| 77 | + { |
| 78 | + return 1; |
| 79 | + } |
77 | 80 |
|
78 | | - if ($output->getFatalCount() > 0) |
79 | | - { |
80 | | - return 1; |
81 | | - } |
82 | | - return 0; |
83 | | - } |
| 81 | + return 0; |
| 82 | + } |
84 | 83 | } |
0 commit comments