package
0.0.0-20221003172846-a3e1774ef349
Repository: https://github.com/dsoprea/go-utility.git
Documentation: pkg.go.dev

# README

GoDoc Build Status Coverage Status Go Report Card

redirect_tty

This will temporarily redirect the process TTY resources to support writing unit-tests directly against main() functions.

handled_exit

Can switch between os.Exit() and panicing a return-code. Supports testing main(). Requires calls to os.Exit() to call Exit() here instead.

# Functions

DisableMarshaledExits disables exit marshaling.
EnableMarshaledExits enables exit marshaling.
Exit will marshal an exit into a panic if marshaling is turned on.
IsTtyRedirected returns whether the TTY is currently redirected.
RedirectTty redirects STDIN, STDOUT, and STDERR to alternative resources.
RestoreAndDumpTty restores original TTY resources but not before grabbing their screen output and then printing it before returning.
RestoreTty restores original TTY resources.
StderrReader returns a reader that can be used to read STDERR output (if redirected).
StdinWriter returns a writer that can be used to feed STDIN data (if redirected).
StdoutReader returns a reader that can be used to read STDOUT output (if redirected).