1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Gerrie package. |
4
|
|
|
* |
5
|
|
|
* (c) Andreas Grunwald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Gerrie\Command; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Console\Command\Command; |
14
|
|
|
use Symfony\Component\Console\Input\InputOption; |
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
16
|
|
|
|
17
|
|
|
class GerrieBaseCommand extends Command |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Adds the --config-file / -c option to the command. |
21
|
|
|
* |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
protected function addConfigFileOption() |
25
|
|
|
{ |
26
|
|
|
$this->addOption( |
27
|
|
|
'config-file', |
28
|
|
|
'c', |
29
|
|
|
InputOption::VALUE_REQUIRED, |
30
|
|
|
'Path to configuration file.' |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Adds several options for database connections to the command. |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
protected function addDatabaseOptions() |
40
|
|
|
{ |
41
|
|
|
$this |
42
|
|
|
->addOption('database-host', 'H', InputOption::VALUE_REQUIRED, 'Name / IP of the host where the database is running.') |
43
|
|
|
->addOption('database-user', 'u', InputOption::VALUE_REQUIRED, 'Username to access the database.') |
44
|
|
|
->addOption('database-pass', 'p', InputOption::VALUE_REQUIRED, 'Password to access the database.') |
45
|
|
|
->addOption('database-port', 'P', InputOption::VALUE_REQUIRED, 'Port where the database is listen.') |
46
|
|
|
->addOption('database-name', 'N', InputOption::VALUE_REQUIRED, 'Name of the database which should be used.'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Adds the SSH Key option to the command. |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
protected function addSSHKeyOption() |
55
|
|
|
{ |
56
|
|
|
$this->addOption( |
57
|
|
|
'ssh-key', |
58
|
|
|
'k', |
59
|
|
|
InputOption::VALUE_REQUIRED, |
60
|
|
|
'Path to SSH private key for authentication via SSH API.' |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Adds the "setup-database-tables" option. |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
|
|
protected function addSetupDatabaseOption() |
70
|
|
|
{ |
71
|
|
|
$this->addOption( |
72
|
|
|
'setup-database-tables', |
73
|
|
|
's', |
74
|
|
|
InputOption::VALUE_NONE, |
75
|
|
|
'Checks if necessary tables are already there. If not this tables will be setted up.' |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Adds the "debug" option. |
81
|
|
|
* This option enables various debug functionalities like |
82
|
|
|
* * Check if every data key received by Gerrit is proceeded by Gerrie |
83
|
|
|
* * Check if an update was processed if the server is crawled the first time |
84
|
|
|
* |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
|
|
protected function addDebugOption() |
88
|
|
|
{ |
89
|
|
|
$this->addOption( |
90
|
|
|
'debug', |
91
|
|
|
'd', |
92
|
|
|
InputOption::VALUE_NONE, |
93
|
|
|
'Enables debug functionality.' |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Adds a argument of a possible list of instances. |
99
|
|
|
* |
100
|
|
|
* Format: scheme://username[:password]@host[:port]/ |
101
|
|
|
* Examples: |
102
|
|
|
* * ssh://[email protected]:29418/'; |
103
|
|
|
* * https://max.mustermann:[email protected]/ |
104
|
|
|
* |
105
|
|
|
* @return void |
106
|
|
|
*/ |
107
|
|
|
protected function addInstancesArgument() |
108
|
|
|
{ |
109
|
|
|
$this->addArgument( |
110
|
|
|
'instances', |
111
|
|
|
InputArgument::IS_ARRAY | InputArgument::OPTIONAL, |
112
|
|
|
'List of instances to crawl separated by whitespace. Format scheme://username[:password]@host[:port]/.' |
113
|
|
|
); |
114
|
|
|
} |
115
|
|
|
} |