1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Wowstack\Dbc\Command; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Command\Command; |
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
10
|
|
|
use Symfony\Component\Console\Input\InputOption; |
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
12
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
13
|
|
|
use Wowstack\Dbc\DBC; |
14
|
|
|
use Wowstack\Dbc\Mapping; |
15
|
|
|
use Wowstack\Dbc\Export\XMLExport; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @codeCoverageIgnore |
19
|
|
|
*/ |
20
|
|
|
class ExportCommand extends Command |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
protected function configure() |
26
|
|
|
{ |
27
|
|
|
$this |
28
|
|
|
->setName('dbc:export') |
29
|
|
|
->setDescription('Dumps the contents of a DBC file.') |
30
|
|
|
->setHelp('This command allows you to dump any DBC file using a file map.') |
31
|
|
|
; |
32
|
|
|
|
33
|
|
|
$this |
34
|
|
|
->addArgument('file', InputArgument::REQUIRED, 'Path to the DBC file') |
35
|
|
|
->addArgument('map', InputArgument::REQUIRED, 'Path to the YAML map') |
36
|
|
|
->addArgument('xml', InputArgument::REQUIRED, 'Where to create the XML dump') |
37
|
|
|
; |
38
|
|
|
|
39
|
|
|
$this |
40
|
|
|
->addOption( |
41
|
|
|
'client-version', |
42
|
|
|
null, |
43
|
|
|
InputOption::VALUE_REQUIRED, |
44
|
|
|
'WoW client version', |
45
|
|
|
'1.12.1' |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
53
|
|
|
{ |
54
|
|
|
$DBC = new DBC($input->getArgument('file'), Mapping::fromYAML($input->getArgument('map'))); |
|
|
|
|
55
|
|
|
$format = 'XML'; |
56
|
|
|
|
57
|
|
|
$styledOutput = new SymfonyStyle($input, $output); |
58
|
|
|
$styledOutput->text([ |
59
|
|
|
sprintf( |
60
|
|
|
'Dumping %s file contents in %s format to %s.', |
61
|
|
|
$DBC->getName(), |
62
|
|
|
$format, |
63
|
|
|
$input->getArgument('xml') |
|
|
|
|
64
|
|
|
), |
65
|
|
|
'', |
66
|
|
|
]); |
67
|
|
|
|
68
|
|
|
$XMLExport = new XMLExport(); |
69
|
|
|
$XMLExport->export($DBC, $input->getArgument('xml'), $input->getOption('client-version')); |
|
|
|
|
70
|
|
|
|
71
|
|
|
foreach ($DBC->getErrors() as $error) { |
72
|
|
|
$output->writeln([ |
73
|
|
|
'#'.$error['record'].' ('.$error['type'].'/'.$error['field'].'): '.$error['hint'], |
|
|
|
|
74
|
|
|
]); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|