1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the wow-apps/symfony-packagist project |
4
|
|
|
* https://github.com/wow-apps/symfony-packagist |
5
|
|
|
* |
6
|
|
|
* (c) 2017 WoW-Apps |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WowApps\PackagistBundle\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
19
|
|
|
use WowApps\PackagistBundle\Service\Packagist; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class WowAppsPackagistListCommand |
23
|
|
|
* |
24
|
|
|
* @author Alexey Samara <[email protected]> |
25
|
|
|
* @package wow-apps/symfony-packagist |
26
|
|
|
*/ |
27
|
|
|
class WowAppsPackagistListCommand extends ContainerAwareCommand |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* return @void |
31
|
|
|
*/ |
32
|
|
|
protected function configure() |
33
|
|
|
{ |
34
|
|
|
$this |
35
|
|
|
->setName('wowapps:packagist:list') |
36
|
|
|
->setDescription('Get packages list') |
37
|
|
|
->addOption( |
38
|
|
|
'vendor', |
39
|
|
|
null, |
40
|
|
|
InputOption::VALUE_OPTIONAL, |
41
|
|
|
'You can set a vendor name to list it\'s packages' |
42
|
|
|
) |
43
|
|
|
->addOption( |
44
|
|
|
'type', |
45
|
|
|
null, |
46
|
|
|
InputOption::VALUE_OPTIONAL, |
47
|
|
|
'You can set a type of packages' |
48
|
|
|
) |
49
|
|
|
; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param InputInterface $input |
54
|
|
|
* @param OutputInterface $output |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
58
|
|
|
{ |
59
|
|
|
/** @var Packagist $packagist */ |
60
|
|
|
$packagist = $this->getContainer()->get('wowapps.packagist'); |
61
|
|
|
$symfonyStyle = new SymfonyStyle($input, $output); |
62
|
|
|
|
63
|
|
|
echo PHP_EOL; |
64
|
|
|
$output->writeln('<bg=green;options=bold;fg=white> </>'); |
65
|
|
|
$output->writeln('<bg=green;options=bold;fg=white> Symfony Packagist API Bundle </>'); |
66
|
|
|
$output->writeln('<bg=green;options=bold;fg=white> </>'); |
67
|
|
|
echo PHP_EOL; |
68
|
|
|
|
69
|
|
|
$symfonyStyle->title('Getting packages list'); |
70
|
|
|
|
71
|
|
|
$packagesList = $packagist->getPackageList($input->getOption('vendor'), $input->getOption('type')); |
72
|
|
|
|
73
|
|
|
$showList = $symfonyStyle->confirm( |
74
|
|
|
sprintf('Founded %d packages. Do you want to show them all?', count($packagesList)), |
75
|
|
|
false |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
if ($showList) { |
79
|
|
|
$symfonyStyle->listing($packagesList); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|