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 Pure\Client; |
11
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterInterface; |
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
13
|
|
|
|
14
|
|
|
class RemoteOutput implements OutputInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var OutputInterface |
18
|
|
|
*/ |
19
|
|
|
private $output; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var Client |
23
|
|
|
*/ |
24
|
|
|
private $pure; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private $server; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param OutputInterface $output |
33
|
|
|
* @param Client $pure |
34
|
|
|
* @param string $server |
35
|
|
|
*/ |
36
|
|
|
public function __construct(OutputInterface $output, Client $pure, $server) |
37
|
|
|
{ |
38
|
|
|
$this->output = $output; |
39
|
|
|
$this->pure = $pure; |
40
|
|
|
$this->server = $server; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
|
public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) |
47
|
|
|
{ |
48
|
|
|
$this->pure->queue('output')->push([$this->server, $messages, $newline, $type]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
|
|
public function writeln($messages, $type = self::OUTPUT_NORMAL) |
55
|
|
|
{ |
56
|
|
|
$this->write($messages, true, $type); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
|
|
public function setVerbosity($level) |
63
|
|
|
{ |
64
|
|
|
throw new \RuntimeException('Can not modify verbosity in parallel mode.'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
|
|
public function getVerbosity() |
71
|
|
|
{ |
72
|
|
|
return $this->output->getVerbosity(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function setDecorated($decorated) |
79
|
|
|
{ |
80
|
|
|
throw new \RuntimeException('Can not modify decorated in parallel mode.'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
|
|
public function isDecorated() |
87
|
|
|
{ |
88
|
|
|
return $this->output->isDecorated(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* {@inheritdoc} |
93
|
|
|
*/ |
94
|
|
|
public function setFormatter(OutputFormatterInterface $formatter) |
95
|
|
|
{ |
96
|
|
|
throw new \RuntimeException('Can not modify formatter in parallel mode.'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
public function getFormatter() |
103
|
|
|
{ |
104
|
|
|
return $this->output->getFormatter(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* {@inheritdoc} |
109
|
|
|
*/ |
110
|
|
|
public function isQuiet() |
111
|
|
|
{ |
112
|
|
|
return self::VERBOSITY_QUIET === $this->getVerbosity(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
|
|
public function isVerbose() |
119
|
|
|
{ |
120
|
|
|
return self::VERBOSITY_VERBOSE <= $this->getVerbosity(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritdoc} |
125
|
|
|
*/ |
126
|
|
|
public function isVeryVerbose() |
127
|
|
|
{ |
128
|
|
|
return self::VERBOSITY_VERY_VERBOSE <= $this->getVerbosity(); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* {@inheritdoc} |
133
|
|
|
*/ |
134
|
|
|
public function isDebug() |
135
|
|
|
{ |
136
|
|
|
return self::VERBOSITY_DEBUG <= $this->getVerbosity(); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|