mirror of
https://github.com/tw93/Mole.git
synced 2026-03-23 00:15:08 +00:00
Improve update checks and cleanup UX, add timeout regressions
This commit is contained in:
@@ -24,6 +24,20 @@ var (
|
||||
jsonOutput = flag.Bool("json", false, "output metrics as JSON instead of TUI")
|
||||
)
|
||||
|
||||
func shouldUseJSONOutput(forceJSON bool, stdout *os.File) bool {
|
||||
if forceJSON {
|
||||
return true
|
||||
}
|
||||
if stdout == nil {
|
||||
return false
|
||||
}
|
||||
info, err := stdout.Stat()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return (info.Mode() & os.ModeCharDevice) == 0
|
||||
}
|
||||
|
||||
type tickMsg struct{}
|
||||
type animTickMsg struct{}
|
||||
|
||||
@@ -246,7 +260,7 @@ func runTUIMode() {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *jsonOutput {
|
||||
if shouldUseJSONOutput(*jsonOutput, os.Stdout) {
|
||||
runJSONMode()
|
||||
} else {
|
||||
runTUIMode()
|
||||
|
||||
Reference in New Issue
Block a user