forked from composer/composer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
IOInterface.php
242 lines (217 loc) · 8.01 KB
/
IOInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\IO;
use Composer\Config;
use Psr\Log\LoggerInterface;
/**
* The Input/Output helper interface.
*
* @author François Pluchino <francois.pluchino@opendisplay.com>
*/
interface IOInterface extends LoggerInterface
{
public const QUIET = 1;
public const NORMAL = 2;
public const VERBOSE = 4;
public const VERY_VERBOSE = 8;
public const DEBUG = 16;
/**
* Is this input means interactive?
*
* @return bool
*/
public function isInteractive();
/**
* Is this output verbose?
*
* @return bool
*/
public function isVerbose();
/**
* Is the output very verbose?
*
* @return bool
*/
public function isVeryVerbose();
/**
* Is the output in debug verbosity?
*
* @return bool
*/
public function isDebug();
/**
* Is this output decorated?
*
* @return bool
*/
public function isDecorated();
/**
* Writes a message to the output.
*
* @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/
public function write($messages, bool $newline = true, int $verbosity = self::NORMAL);
/**
* Writes a message to the error output.
*
* @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/
public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL);
/**
* Writes a message to the output, without formatting it.
*
* @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/
public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
/**
* Writes a message to the error output, without formatting it.
*
* @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not
* @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/
public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
/**
* Overwrites a previous message to the output.
*
* @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not
* @param int $size The size of line
* @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/
public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
/**
* Overwrites a previous message to the error output.
*
* @param string|string[] $messages The message as an array of lines or a single string
* @param bool $newline Whether to add a newline or not
* @param int $size The size of line
* @param int $verbosity Verbosity level from the VERBOSITY_* constants
*
* @return void
*/
public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
/**
* Asks a question to the user.
*
* @param string $question The question to ask
* @param string|bool|int|float|null $default The default answer if none is given by the user
*
* @throws \RuntimeException If there is no data to read in the input stream
* @return mixed The user answer
*/
public function ask(string $question, $default = null);
/**
* Asks a confirmation to the user.
*
* The question will be asked until the user answers by nothing, yes, or no.
*
* @param string $question The question to ask
* @param bool $default The default answer if the user enters nothing
*
* @return bool true if the user has confirmed, false otherwise
*/
public function askConfirmation(string $question, bool $default = true);
/**
* Asks for a value and validates the response.
*
* The validator receives the data to validate. It must return the
* validated data when the data is valid and throw an exception
* otherwise.
*
* @param string $question The question to ask
* @param callable $validator A PHP callback
* @param null|int $attempts Max number of times to ask before giving up (default of null means infinite)
* @param mixed $default The default answer if none is given by the user
*
* @throws \Exception When any of the validators return an error
* @return mixed
*/
public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);
/**
* Asks a question to the user and hide the answer.
*
* @param string $question The question to ask
*
* @return string|null The answer
*/
public function askAndHideAnswer(string $question);
/**
* Asks the user to select a value.
*
* @param string $question The question to ask
* @param string[] $choices List of choices to pick from
* @param bool|string $default The default answer if the user enters nothing
* @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite)
* @param string $errorMessage Message which will be shown if invalid value from choice list would be picked
* @param bool $multiselect Select more than one value separated by comma
*
* @throws \InvalidArgumentException
* @return int|string|string[]|bool The selected value or values (the key of the choices array)
*/
public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);
/**
* Get all authentication information entered.
*
* @return array<string, array{username: string|null, password: string|null}> The map of authentication data
*/
public function getAuthentications();
/**
* Verify if the repository has a authentication information.
*
* @param string $repositoryName The unique name of repository
*
* @return bool
*/
public function hasAuthentication(string $repositoryName);
/**
* Get the username and password of repository.
*
* @param string $repositoryName The unique name of repository
*
* @return array{username: string|null, password: string|null}
*/
public function getAuthentication(string $repositoryName);
/**
* Set the authentication information for the repository.
*
* @param string $repositoryName The unique name of repository
* @param string $username The username
* @param null|string $password The password
*
* @return void
*/
public function setAuthentication(string $repositoryName, string $username, ?string $password = null);
/**
* Loads authentications from a config instance
*
* @param Config $config
*
* @return void
*/
public function loadConfiguration(Config $config);
}