@@ -15,16 +15,34 @@ interface Console
1515{
1616 public function call (string |array $ command , string |array $ arguments = []): ExitCode |int ;
1717
18+ /**
19+ * Reads a line from the console input.
20+ */
1821 public function readln (): string ;
1922
23+ /**
24+ * Reads the specified number of bytes from the console input.
25+ */
2026 public function read (int $ bytes ): string ;
2127
28+ /**
29+ * Writes the specified `$contents` to the console output.
30+ */
2231 public function write (string $ contents ): self ;
2332
33+ /**
34+ * Writes the specified `$contents` to the console output and appends a new line.
35+ */
2436 public function writeln (string $ line = '' ): self ;
2537
38+ /**
39+ * Writes the specified `$contents` to the console output, without formatting.
40+ */
2641 public function writeRaw (string $ contents ): self ;
2742
43+ /**
44+ * Writes the specified `$contents` to the console output with the specified syntax highlighting.
45+ */
2846 public function writeWithLanguage (string $ contents , Language $ language ): self ;
2947
3048 /**
@@ -33,6 +51,8 @@ public function writeWithLanguage(string $contents, Language $language): self;
3351 public function component (InteractiveConsoleComponent $ component , array $ validation = []): mixed ;
3452
3553 /**
54+ * Asks the user a question and returns the answer.
55+ *
3656 * @param null|array|iterable|class-string<BackedEnum> $options
3757 * @param mixed|null $default
3858 * @param \Tempest\Validation\Rule[] $validation
@@ -48,48 +68,93 @@ public function ask(
4868 array $ validation = [],
4969 ): null |int |string |Stringable |UnitEnum |array ;
5070
71+ /**
72+ * Asks the user a question and returns the answer.
73+ */
5174 public function confirm (string $ question , bool $ default = false , ?string $ yes = null , ?string $ no = null ): bool ;
5275
76+ /**
77+ * Prompts the user for a password and returns it.
78+ */
5379 public function password (string $ label = 'Password ' , bool $ confirm = false , array $ validation = []): ?string ;
5480
81+ /**
82+ * Progresses through the specified `$data` using the specified `$handler`.
83+ */
5584 public function progressBar (iterable $ data , Closure $ handler ): array ;
5685
5786 /**
87+ * Asks the user to select an option from a list using a closure.
88+ *
5889 * @param Closure(string $search): array $search
5990 */
6091 public function search (string $ label , Closure $ search , bool $ multiple = false , null |string |array $ default = null ): mixed ;
6192
93+ /**
94+ * Displays the progress of a task.
95+ */
6296 public function task (string $ label , null |Process |Closure $ handler ): bool ;
6397
98+ /**
99+ * Displays a header.
100+ */
64101 public function header (string $ header , ?string $ subheader = null ): self ;
65102
103+ /**
104+ * Displays information to the user.
105+ */
66106 public function info (string $ contents , ?string $ title = null ): self ;
67107
108+ /**
109+ * Displays an error message to the user.
110+ */
68111 public function error (string $ contents , ?string $ title = null ): self ;
69112
113+ /**
114+ * Displays a warning to the user.
115+ */
70116 public function warning (string $ contents , ?string $ title = null ): self ;
71117
118+ /**
119+ * Displays a success message to the user.
120+ */
72121 public function success (string $ contents , ?string $ title = null ): self ;
73122
123+ /**
124+ * Displays a key/value pair in a line.
125+ */
74126 public function keyValue (string $ key , ?string $ value = null , bool $ useAvailableWidth = false ): self ;
75127
128+ /**
129+ * Displays instructions to the user. Can be an array of lines.
130+ */
76131 public function instructions (array |string $ lines ): self ;
77132
78133 /**
134+ * Applies the specified `$callback` when the `$condition` is `true`.
135+ *
79136 * @param mixed|Closure(self): bool $condition
80137 * @param Closure(self): self $callback
81138 */
82139 public function when (mixed $ condition , Closure $ callback ): self ;
83140
84141 /**
142+ * Applies the specified `$callback` unless the `$condition` is `true`.
143+ *
85144 * @param mixed|Closure(self): bool $condition
86145 * @param Closure(self): self $callback
87146 */
88147 public function unless (mixed $ condition , Closure $ callback ): self ;
89148
90149 public function withLabel (string $ label ): self ;
91150
151+ /**
152+ * Whether the console is interactive.
153+ */
92154 public function supportsPrompting (): bool ;
93155
156+ /**
157+ * Forces the console to not be interactive.
158+ */
94159 public function disablePrompting (): self ;
95160}
0 commit comments