1
0
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:
tw93
2026-03-05 12:00:07 +08:00
parent fbee8da9f7
commit 8e4b8a5e0d
21 changed files with 948 additions and 164 deletions

View File

@@ -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()