NewUI will return a UI object where Out is set to STDOUT, In is set to STDIN, and Err is set to STDERR
(config Config)
| 101 | // NewUI will return a UI object where Out is set to STDOUT, In is set to |
| 102 | // STDIN, and Err is set to STDERR |
| 103 | func NewUI(config Config) (*UI, error) { |
| 104 | translateFunc, err := GetTranslationFunc(config) |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | |
| 109 | location := time.Now().Location() |
| 110 | |
| 111 | return &UI{ |
| 112 | In: os.Stdin, |
| 113 | Out: color.Output, |
| 114 | OutForInteraction: os.Stdout, |
| 115 | Err: os.Stderr, |
| 116 | colorEnabled: config.ColorEnabled(), |
| 117 | translate: translateFunc, |
| 118 | terminalLock: &sync.Mutex{}, |
| 119 | Exiter: realExiter, |
| 120 | fileLock: &sync.Mutex{}, |
| 121 | Interactor: realInteract, |
| 122 | IsTTY: config.IsTTY(), |
| 123 | TerminalWidth: config.TerminalWidth(), |
| 124 | TimezoneLocation: location, |
| 125 | }, nil |
| 126 | } |
| 127 | |
| 128 | // NewPluginUI will return a UI object where OUT and ERR are customizable. |
| 129 | func NewPluginUI(config Config, outBuffer io.Writer, errBuffer io.Writer) (*UI, error) { |
no test coverage detected