1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Spiral Framework. |
5
|
|
|
* |
6
|
|
|
* @license MIT |
7
|
|
|
* @author Anton Titov (Wolfy-J) |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Spiral\Console; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Provides the ability to inject desired command name into Symfony\Console\Application->doRun(); |
19
|
|
|
*/ |
20
|
|
|
final class InputProxy implements InputInterface |
21
|
|
|
{ |
22
|
|
|
/** @var InputInterface */ |
23
|
|
|
private $input; |
24
|
|
|
|
25
|
|
|
/** @var array */ |
26
|
|
|
private $overwrite; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param InputInterface $input |
30
|
|
|
* @param array $overwrite |
31
|
|
|
*/ |
32
|
|
|
public function __construct(InputInterface $input, array $overwrite) |
33
|
|
|
{ |
34
|
|
|
$this->input = $input; |
35
|
|
|
$this->overwrite = $overwrite; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @inheritDoc |
40
|
|
|
*/ |
41
|
|
|
public function getFirstArgument() |
42
|
|
|
{ |
43
|
|
|
return $this->overwrite['firstArgument'] ?? $this->input->getFirstArgument(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @inheritDoc |
48
|
|
|
*/ |
49
|
|
|
public function hasParameterOption($values, $onlyParams = false) |
50
|
|
|
{ |
51
|
|
|
return $this->input->hasParameterOption($values, $onlyParams = false); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @inheritDoc |
56
|
|
|
*/ |
57
|
|
|
public function getParameterOption($values, $default = false, $onlyParams = false) |
58
|
|
|
{ |
59
|
|
|
return $this->input->getParameterOption($values, $default = false, $onlyParams = false); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @inheritDoc |
64
|
|
|
*/ |
65
|
|
|
public function bind(InputDefinition $definition) |
66
|
|
|
{ |
67
|
|
|
return $this->input->bind($definition); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @inheritDoc |
72
|
|
|
*/ |
73
|
|
|
public function validate() |
74
|
|
|
{ |
75
|
|
|
return $this->input->validate(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @inheritDoc |
80
|
|
|
*/ |
81
|
|
|
public function getArguments() |
82
|
|
|
{ |
83
|
|
|
return $this->input->getArguments(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @inheritDoc |
88
|
|
|
*/ |
89
|
|
|
public function getArgument($name) |
90
|
|
|
{ |
91
|
|
|
return $this->input->getArgument($name); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @inheritDoc |
96
|
|
|
*/ |
97
|
|
|
public function setArgument($name, $value) |
98
|
|
|
{ |
99
|
|
|
return $this->input->setArgument($name, $value); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @inheritDoc |
104
|
|
|
*/ |
105
|
|
|
public function hasArgument($name) |
106
|
|
|
{ |
107
|
|
|
return $this->input->hasArgument($name); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @inheritDoc |
112
|
|
|
*/ |
113
|
|
|
public function getOptions() |
114
|
|
|
{ |
115
|
|
|
return $this->input->getOptions(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @inheritDoc |
120
|
|
|
*/ |
121
|
|
|
public function getOption($name) |
122
|
|
|
{ |
123
|
|
|
return $this->input->getOption($name); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @inheritDoc |
128
|
|
|
*/ |
129
|
|
|
public function setOption($name, $value) |
130
|
|
|
{ |
131
|
|
|
return $this->input->setOption($name, $value); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @inheritDoc |
136
|
|
|
*/ |
137
|
|
|
public function hasOption($name) |
138
|
|
|
{ |
139
|
|
|
return $this->input->hasOption($name); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @inheritDoc |
144
|
|
|
*/ |
145
|
|
|
public function isInteractive() |
146
|
|
|
{ |
147
|
|
|
return $this->input->isInteractive(); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @inheritDoc |
152
|
|
|
*/ |
153
|
|
|
public function setInteractive($interactive) |
154
|
|
|
{ |
155
|
|
|
return $this->input->setInteractive($interactive); |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|