Documentation
¶
Overview ¶
StreamManager manages all I/O streams for the CLI. All methods are safe for concurrent use.
Index ¶
- type StreamManager
- func (sm *StreamManager) Close()
- func (sm *StreamManager) DisableTee()
- func (sm *StreamManager) EnableTee(filePath string, silent bool) error
- func (sm *StreamManager) GetErrStream() io.Writer
- func (sm *StreamManager) GetInStream() io.ReadCloser
- func (sm *StreamManager) GetOutStream() io.Writer
- func (sm *StreamManager) GetTerminalWidth() (int, error)
- func (sm *StreamManager) GetTerminalWidthString() string
- func (sm *StreamManager) GetTtyStream() *os.File
- func (sm *StreamManager) GetWriter() io.Writer
- func (sm *StreamManager) IsEnabled() bool
- func (sm *StreamManager) IsInSilentTeeMode() bool
- func (sm *StreamManager) IsTerminal() bool
- func (sm *StreamManager) SetTtyStream(tty *os.File)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StreamManager ¶
type StreamManager struct {
// contains filtered or unexported fields
}
StreamManager manages all input/output streams for the CLI. It centralizes handling of stdin, stdout, stderr, TTY operations, and tee functionality. This component ensures proper separation between data output (which may be tee'd) and terminal control operations (which should not be tee'd). It consolidates stream handling, tee functionality, and terminal operations
func NewStreamManager ¶
func NewStreamManager(inStream io.ReadCloser, outStream, errStream io.Writer) *StreamManager
NewStreamManager creates a new StreamManager instance
func (*StreamManager) Close ¶
func (sm *StreamManager) Close()
Close closes any open tee file and cleans up resources
func (*StreamManager) DisableTee ¶
func (sm *StreamManager) DisableTee()
DisableTee stops tee output and closes the tee file
func (*StreamManager) EnableTee ¶
func (sm *StreamManager) EnableTee(filePath string, silent bool) error
EnableTee starts tee output to the specified file If silent is true, output goes only to the file (not stdout)
func (*StreamManager) GetErrStream ¶
func (sm *StreamManager) GetErrStream() io.Writer
GetErrStream returns the error stream
func (*StreamManager) GetInStream ¶
func (sm *StreamManager) GetInStream() io.ReadCloser
GetInStream returns the input stream
func (*StreamManager) GetOutStream ¶
func (sm *StreamManager) GetOutStream() io.Writer
GetOutStream returns the original output stream (without tee/redirect) This should ONLY be used for:
- Terminal control operations (prompts, progress bars)
- Interactive UI elements that should always display on screen
For all query results and data output, use GetWriter() instead to respect tee and output redirect settings.
func (*StreamManager) GetTerminalWidth ¶
func (sm *StreamManager) GetTerminalWidth() (int, error)
GetTerminalWidth returns the current terminal width Returns 0 and an error if the output is not a terminal
func (*StreamManager) GetTerminalWidthString ¶
func (sm *StreamManager) GetTerminalWidthString() string
GetTerminalWidthString returns the terminal width as a string Returns "NULL" if the terminal width cannot be determined
func (*StreamManager) GetTtyStream ¶
func (sm *StreamManager) GetTtyStream() *os.File
GetTtyStream returns the TTY stream for terminal operations
func (*StreamManager) GetWriter ¶
func (sm *StreamManager) GetWriter() io.Writer
GetWriter returns the current output writer (respects tee/redirect settings) This should be used for ALL data output including:
- Query results
- SQL statements (DUMP, SELECT, etc.)
- Data exports
- Any content that should be captured when tee or output redirect is active
func (*StreamManager) IsEnabled ¶
func (sm *StreamManager) IsEnabled() bool
IsEnabled returns whether tee output is currently active
func (*StreamManager) IsInSilentTeeMode ¶
func (sm *StreamManager) IsInSilentTeeMode() bool
IsInSilentTeeMode returns whether tee output is in silent mode (file only)
func (*StreamManager) IsTerminal ¶
func (sm *StreamManager) IsTerminal() bool
IsTerminal returns whether the output is a terminal
func (*StreamManager) SetTtyStream ¶
func (sm *StreamManager) SetTtyStream(tty *os.File)
SetTtyStream sets the TTY stream for terminal operations This is useful when the original output is not a TTY (e.g., when piped)