mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
29 lines
562 B
Go
29 lines
562 B
Go
package ui
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
|
|
"github.com/anchore/syft/internal/ui/etui"
|
|
"golang.org/x/crypto/ssh/terminal"
|
|
)
|
|
|
|
// TODO: build tags to exclude options from windows
|
|
|
|
func Select(verbose, quiet bool) UI {
|
|
var ui UI
|
|
|
|
isStdoutATty := terminal.IsTerminal(int(os.Stdout.Fd()))
|
|
isStderrATty := terminal.IsTerminal(int(os.Stderr.Fd()))
|
|
notATerminal := !isStderrATty && !isStdoutATty
|
|
|
|
switch {
|
|
case runtime.GOOS == "windows" || verbose || quiet || notATerminal || !isStderrATty:
|
|
ui = LoggerUI
|
|
default:
|
|
ui = etui.OutputToEphemeralTUI
|
|
}
|
|
|
|
return ui
|
|
}
|