mirror of
https://github.com/anchore/syft
synced 2024-11-13 23:57:07 +00:00
51b9c73c31
* add basic documentation for catalogers (with refactoring for simplification) Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add docs for catalog parsers, UI, and event bus Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update bus phrasing Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
30 lines
747 B
Go
30 lines
747 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
|
|
|
|
// Select is responsible for determining the specific UI function given select user option, the current platform
|
|
// config values, and environment status (such as a TTY being present).
|
|
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
|
|
}
|