1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the slack-cli package. |
5
|
|
|
* |
6
|
|
|
* (c) Cas Leentfaar <[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 CL\SlackCli\Console; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Application as BaseApplication; |
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Cas Leentfaar <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class Application extends BaseApplication |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
private $availableEnvironments = [ |
26
|
|
|
'prod', |
27
|
|
|
'test-success', // mocks a successful response |
28
|
|
|
'test-failure', // mocks a failed response |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $defaultEnvironment = 'prod'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Constructor. |
38
|
|
|
*/ |
39
|
24 |
|
public function __construct() |
40
|
|
|
{ |
41
|
24 |
|
error_reporting(-1); |
42
|
|
|
|
43
|
24 |
|
parent::__construct('Slack CLI', $this->getReplacedVersion()); |
44
|
24 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public function getLongVersion() |
50
|
|
|
{ |
51
|
|
|
return sprintf('%s by <comment>Cas Leentfaar</comment>', parent::getLongVersion()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
24 |
|
protected function getDefaultInputDefinition() |
58
|
|
|
{ |
59
|
24 |
|
$parentDefinition = parent::getDefaultInputDefinition(); |
60
|
24 |
|
$parentDefinition->addOption(new InputOption( |
61
|
24 |
|
'--env', |
62
|
24 |
|
'e', |
63
|
24 |
|
InputOption::VALUE_REQUIRED, |
64
|
24 |
|
sprintf('The environment to run the Slack CLI under (%s)', implode('|', $this->availableEnvironments)), |
65
|
24 |
|
$this->defaultEnvironment |
66
|
24 |
|
)); |
67
|
|
|
|
68
|
24 |
|
return $parentDefinition; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return null|string |
73
|
|
|
*/ |
74
|
24 |
|
private function getReplacedVersion() |
75
|
|
|
{ |
76
|
24 |
|
$version = '@git-version@'; |
77
|
24 |
|
if ($version === '@' . 'git-version@') { |
78
|
24 |
|
return 'UNKNOWN'; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $version; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|