2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								package ui
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-14 19:21:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import (
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"context"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									"io"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								)
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-15 21:04:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// Terminal is used to write messages and display status lines which can be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// updated. See termstatus.Terminal for a concrete implementation.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								type Terminal interface {
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 16:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// Print writes a line to the terminal. Appends a newline if not present.
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Print(line string)
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 16:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// Error writes an error to the terminal. Appends a newline if not present.
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Error(line string)
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 16:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// SetStatus sets the status lines to the terminal.
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									SetStatus(lines []string)
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 16:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// CanUpdateStatus returns true if the terminal can update the status lines.
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									CanUpdateStatus() bool
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-20 23:06:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-18 22:17:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									InputRaw() io.ReadCloser
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									InputIsTerminal() bool
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-14 19:21:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ReadPassword(ctx context.Context, prompt string) (string, error)
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-20 23:06:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									OutputWriter() io.Writer
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-21 16:32:00 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// OutputRaw returns the output writer. Should only be used if there is no
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// other option. Must not be used in combination with Print, Error, SetStatus
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// or any other method that writes to the terminal.
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-15 21:04:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									OutputRaw() io.Writer
							 | 
						
					
						
							
								
									
										
										
										
											2025-09-14 17:58:52 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									OutputIsTerminal() bool
							 | 
						
					
						
							
								
									
										
										
										
											2024-07-27 19:06:26 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |