|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Clover to Html package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Stéphane Demonchaux <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
namespace CloverToHtml\Command; |
|
12
|
|
|
|
|
13
|
|
|
use CloverToHtml\Converter; |
|
14
|
|
|
use Symfony\Component\Console\Command\Command; |
|
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Convert command. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Stéphane Demonchaux |
|
23
|
|
|
*/ |
|
24
|
|
|
class ConvertCommand extends Command |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var Converter |
|
28
|
|
|
*/ |
|
29
|
|
|
private $engine; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param Converter $engine |
|
33
|
|
|
*/ |
|
34
|
2 |
|
public function __construct(Converter $engine) |
|
35
|
|
|
{ |
|
36
|
2 |
|
$this->engine = $engine; |
|
37
|
2 |
|
parent::__construct(); |
|
38
|
2 |
|
} |
|
39
|
|
|
|
|
40
|
|
|
/* (non-PHPdoc) |
|
41
|
|
|
* @see \Symfony\Component\Console\Command\Command::configure() |
|
42
|
|
|
*/ |
|
43
|
2 |
|
protected function configure(): void |
|
44
|
|
|
{ |
|
45
|
2 |
|
$this |
|
46
|
2 |
|
->setName('cloverToHtml:convert') |
|
47
|
2 |
|
->setDescription('Convert a clover.xml to html') |
|
48
|
2 |
|
->addArgument('source', InputArgument::REQUIRED, 'clover.xml') |
|
49
|
2 |
|
->addArgument('target', InputArgument::REQUIRED, 'target') |
|
50
|
2 |
|
->addOption('template', null, null, 'Custom template path'); |
|
51
|
2 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/* (non-PHPdoc) |
|
54
|
|
|
* @see \Symfony\Component\Console\Command\Command::execute() |
|
55
|
|
|
*/ |
|
56
|
1 |
|
public function execute(InputInterface $input, OutputInterface $output) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->engine->convert( |
|
59
|
|
|
$input->getArgument('source'), |
|
60
|
1 |
|
$input->getArgument('target'), |
|
61
|
|
|
$input->getOption('template') ?: null |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
|
|
$output->writeLn(sprintf('Coverage generated in %s', $input->getArgument('target'))); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|