|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of CaptainHook |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Sebastian Feldmann <[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
|
|
|
|
|
12
|
|
|
namespace CaptainHook\App\Console\Command; |
|
13
|
|
|
|
|
14
|
|
|
use CaptainHook\App\Console\IOUtil; |
|
15
|
|
|
use CaptainHook\App\Runner\Config\Reader; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
17
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
19
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Command to display configuration information |
|
23
|
|
|
* |
|
24
|
|
|
* @package CaptainHook |
|
25
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
26
|
|
|
* @link https://github.com/captainhookphp/captainhook |
|
27
|
|
|
* @since Class available since Release 5.24.0 |
|
28
|
|
|
*/ |
|
29
|
|
|
class Info extends RepositoryAware |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Configure the command |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
3 |
|
protected function configure(): void |
|
37
|
|
|
{ |
|
38
|
3 |
|
parent::configure(); |
|
39
|
3 |
|
$this->setName('config:info') |
|
40
|
3 |
|
->setAliases(['info']) |
|
41
|
3 |
|
->setDescription('Displays information about the configuration') |
|
42
|
3 |
|
->setHelp('Displays information about the configuration') |
|
43
|
3 |
|
->addArgument('hook', InputArgument::OPTIONAL, 'Hook you want to investigate') |
|
44
|
3 |
|
->addOption( |
|
45
|
3 |
|
'list-actions', |
|
46
|
3 |
|
'a', |
|
47
|
3 |
|
InputOption::VALUE_NONE, |
|
48
|
3 |
|
'List all actions' |
|
49
|
3 |
|
) |
|
50
|
3 |
|
->addOption( |
|
51
|
3 |
|
'list-conditions', |
|
52
|
3 |
|
'p', |
|
53
|
3 |
|
InputOption::VALUE_NONE, |
|
54
|
3 |
|
'List all conditions' |
|
55
|
3 |
|
) |
|
56
|
3 |
|
->addOption( |
|
57
|
3 |
|
'list-options', |
|
58
|
3 |
|
'o', |
|
59
|
3 |
|
InputOption::VALUE_NONE, |
|
60
|
3 |
|
'List all options' |
|
61
|
3 |
|
) |
|
62
|
3 |
|
->addOption( |
|
63
|
3 |
|
'list-config', |
|
64
|
3 |
|
's', |
|
65
|
3 |
|
InputOption::VALUE_NONE, |
|
66
|
3 |
|
'List all config settings' |
|
67
|
3 |
|
) |
|
68
|
3 |
|
->addOption( |
|
69
|
3 |
|
'extensive', |
|
70
|
3 |
|
'e', |
|
71
|
3 |
|
InputOption::VALUE_NONE, |
|
72
|
3 |
|
'Show more detailed information' |
|
73
|
3 |
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Execute the command |
|
78
|
|
|
* |
|
79
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
|
80
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
|
81
|
|
|
* @return int |
|
82
|
|
|
* @throws \CaptainHook\App\Exception\InvalidHookName |
|
83
|
|
|
* @throws \Exception |
|
84
|
|
|
*/ |
|
85
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
86
|
|
|
{ |
|
87
|
2 |
|
$io = $this->getIO($input, $output); |
|
88
|
2 |
|
$config = $this->createConfig($input, true, ['git-directory']); |
|
89
|
1 |
|
$repo = $this->createRepository(dirname($config->getGitDirectory())); |
|
90
|
|
|
|
|
91
|
1 |
|
$editor = new Reader($io, $config, $repo); |
|
92
|
1 |
|
$editor->setHook(IOUtil::argToString($input->getArgument('hook'))) |
|
93
|
1 |
|
->display(Reader::OPT_ACTIONS, $input->getOption('list-actions')) |
|
94
|
1 |
|
->display(Reader::OPT_CONDITIONS, $input->getOption('list-conditions')) |
|
95
|
1 |
|
->display(Reader::OPT_OPTIONS, $input->getOption('list-options')) |
|
96
|
1 |
|
->extensive($input->getOption('extensive')) |
|
97
|
1 |
|
->run(); |
|
98
|
|
|
|
|
99
|
1 |
|
return 0; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|