-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathIOutput.php
More file actions
158 lines (139 loc) · 3.92 KB
/
Copy pathIOutput.php
File metadata and controls
158 lines (139 loc) · 3.92 KB
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
<?php
declare(strict_types=1);
// SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
// SPDX-License-Identifier: AGPL-3.0-or-later
namespace OCP\Console;
use OCP\AppFramework\Attribute\Consumable;
/**
* Interface that lets you output content from a command.
*
* @since 35.0.0
*/
#[Consumable(since: '35.0.0')]
interface IOutput {
/**
* Writes a message to the output.
*
* @param bool $newline Whether to add a newline
* @param Verbosity $verbosity Only write messages if verbosity is set to at least that level.
* @since 35.0.0
*/
public function write(string|iterable $messages, bool $newline = false, Verbosity $verbosity = Verbosity::Normal): void;
/**
* Writes a message to the output and adds a newline at the end.
*
* @param Verbosity $verbosity Only write messages if verbosity is set to at least that level.
* @since 35.0.0
*/
public function writeln(string|iterable $messages, Verbosity $verbosity = Verbosity::Normal): void;
/**
* Sets the verbosity of the output.
* @since 35.0.0
*/
public function setVerbosity(Verbosity $level): void;
/**
* Gets the current verbosity of the output.
* @since 35.0.0
*/
public function getVerbosity(): Verbosity;
/**
* Returns whether verbosity is quiet (-q).
* @since 35.0.0
*/
public function isQuiet() : bool;
/**
* Returns whether verbosity is verbose (-v).
* @since 35.0.0
*/
public function isVerbose() : bool;
/**
* Returns whether verbosity is very verbose (-vv).
* @since 35.0.0
*/
public function isVeryVerbose() : bool;
/**
* Returns whether verbosity is debug (-vvv).
* @since 35.0.0
*/
public function isDebug() : bool;
/**
* Write a list of items in the format specified with --output
*
* @param array $items
* @since 35.0.0
*/
public function writeArrayInOutputFormat(iterable $items, string $prefix = ' - '): void;
/**
* Write a multidimensional array of items in the format specified with --output
*
* @param list<array<string, mixed>> $items
* @since 35.0.0
*/
public function writeTableInOutputFormat(array $items): void;
/**
* Write a multidimensional iterator of items in the format specified with --output
*
* @param \Iterator<array<string, mixed>> $items
* @since 35.0.0
*/
public function writeStreamingTableInOutputFormat(\Iterator $items, int $tableGroupSize): void;
/**
* Displays a progress bar with a number of steps equal to the argument passed to the method (don't pass any value if the length of the progress bar is unknown):
*
* ```
* // displays a progress bar of unknown length
* $output->progressStart();
* ```
*
* ```
* // displays a 100-step length progress bar
* $output->progressStart(100);
* ```
* @since 35.0.0
*/
public function progressStart(int $max = 0): void;
/**
* Make the progress bar advance the given number of steps (or 1 step if no argument is passed):
*
* ```
* // advances the progress bar 1 step
* $output->progressAdvance();
* ```
*
* ```
* // advances the progress bar 10 steps
* $output->progressAdvance(10);
* ```
* @since 35.0.0
*/
public function progressAdvance(int $step = 1): void;
/**
* Finish the progress bar (filling up all the remaining steps when its length is known):
*
* ```
* $output->progressFinish();
* ```
* @since 35.0.0
*/
public function progressFinish(): void;
/**
* If your progress bar loops over an iterable collection, use the progressIterate() helper:
*
* ```
* $iterable = [1, 2];
*
* foreach ($output->progressIterate($iterable) as $value) {
* // ... do some work
* }
* ```
* @template TKey
* @template TValue
*
* @param iterable<TKey, TValue> $iterable
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
*
* @return iterable<TKey, TValue>
* @since 35.0.0
*/
public function progressIterate(iterable $iterable, ?int $max = null): iterable;
}