|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace wapmorgan\UnifiedArchive\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Helper\Table; |
|
6
|
|
|
use Symfony\Component\Console\Helper\TableCell; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use wapmorgan\UnifiedArchive\Formats; |
|
10
|
|
|
|
|
11
|
|
|
class FormatsCommand extends BaseCommand |
|
12
|
|
|
{ |
|
13
|
|
|
protected static $defaultName = 'system:formats'; |
|
14
|
|
|
|
|
15
|
|
|
protected function configure() |
|
16
|
|
|
{ |
|
17
|
|
|
$this |
|
18
|
|
|
->setDescription('Lists supported archive formats with current system configuration') |
|
19
|
|
|
->setHelp('Lists supported archive formats with current system configuration. You can check supported formats and supported actions with them.') |
|
20
|
|
|
; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
|
24
|
|
|
{ |
|
25
|
|
|
$table = new Table($output); |
|
26
|
|
|
$table->setHeaders(['format', 'open', 'stream', 'create', 'append', 'update', 'encrypt', 'drivers']); |
|
27
|
|
|
|
|
28
|
|
|
$i = 0; |
|
29
|
|
|
foreach (Formats::getFormatsReport() as $format => $config) { |
|
30
|
|
|
$table->setRow($i++, [ |
|
31
|
|
|
$format, |
|
32
|
|
|
$config['open'] ? '+' : '', |
|
33
|
|
|
$config['stream'] ? '+' : '', |
|
34
|
|
|
$config['create'] ? '+' : '', |
|
35
|
|
|
$config['append'] ? '+' : '', |
|
36
|
|
|
$config['update'] ? '+' : '', |
|
37
|
|
|
$config['encrypt'] ? '+' : '', |
|
38
|
|
|
new TableCell(implode("\n", $config['drivers']), ['rowspan' => count($config['drivers'])]) |
|
39
|
|
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
$table->render(); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|