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