1
|
|
|
<?php |
2
|
|
|
/* (c) Anton Medvedev <[email protected]> |
3
|
|
|
* |
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
5
|
|
|
* file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Deployer\Console\Output; |
9
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterInterface; |
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
12
|
|
|
|
13
|
|
|
class OutputWatcher implements OutputInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var OutputInterface |
17
|
|
|
*/ |
18
|
|
|
private $output; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var bool |
22
|
|
|
*/ |
23
|
|
|
private $wasWritten = false; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param OutputInterface $output |
27
|
|
|
*/ |
28
|
4 |
|
public function __construct(OutputInterface $output) |
29
|
|
|
{ |
30
|
4 |
|
$this->output = $output; |
31
|
4 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
4 |
|
public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) |
37
|
|
|
{ |
38
|
4 |
|
$this->wasWritten = true; |
39
|
4 |
|
$this->output->write($messages, $newline, $type); |
40
|
4 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
5 |
|
public function writeln($messages, $type = self::OUTPUT_NORMAL) |
46
|
|
|
{ |
47
|
5 |
|
$this->write($messages, true, $type); |
48
|
5 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
1 |
|
public function setVerbosity($level) |
54
|
|
|
{ |
55
|
1 |
|
$this->output->setVerbosity($level); |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
4 |
|
public function getVerbosity() |
62
|
|
|
{ |
63
|
4 |
|
return $this->output->getVerbosity(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
1 |
|
public function setDecorated($decorated) |
70
|
|
|
{ |
71
|
1 |
|
$this->output->setDecorated($decorated); |
72
|
1 |
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
4 |
|
public function isDecorated() |
78
|
|
|
{ |
79
|
4 |
|
return $this->output->isDecorated(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritdoc} |
84
|
|
|
*/ |
85
|
1 |
|
public function setFormatter(OutputFormatterInterface $formatter) |
86
|
|
|
{ |
87
|
1 |
|
$this->output->setFormatter($formatter); |
88
|
1 |
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritdoc} |
92
|
|
|
*/ |
93
|
1 |
|
public function getFormatter() |
94
|
|
|
{ |
95
|
1 |
|
return $this->output->getFormatter(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param boolean $wasWritten |
100
|
|
|
*/ |
101
|
5 |
|
public function setWasWritten($wasWritten) |
102
|
|
|
{ |
103
|
5 |
|
$this->wasWritten = $wasWritten; |
104
|
5 |
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return boolean |
108
|
|
|
*/ |
109
|
1 |
|
public function getWasWritten() |
110
|
|
|
{ |
111
|
1 |
|
return $this->wasWritten; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* {@inheritdoc} |
116
|
|
|
*/ |
117
|
|
|
public function isQuiet() |
118
|
|
|
{ |
119
|
|
|
return self::VERBOSITY_QUIET === $this->getVerbosity(); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* {@inheritdoc} |
124
|
|
|
*/ |
125
|
|
|
public function isVerbose() |
126
|
|
|
{ |
127
|
|
|
return self::VERBOSITY_VERBOSE <= $this->getVerbosity(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* {@inheritdoc} |
132
|
|
|
*/ |
133
|
|
|
public function isVeryVerbose() |
134
|
|
|
{ |
135
|
|
|
return self::VERBOSITY_VERY_VERBOSE <= $this->getVerbosity(); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* {@inheritdoc} |
140
|
|
|
*/ |
141
|
|
|
public function isDebug() |
142
|
|
|
{ |
143
|
|
|
return self::VERBOSITY_DEBUG <= $this->getVerbosity(); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|