refactor(M8): drop go-isatty dep for stdlib ModeCharDevice (ponytail) ♻️

isTTY only gates a cosmetic status enrichment; os.Stdout.Stat() &
ModeCharDevice is the stdlib one-liner. Cygwin detection is moot on a
mac/Linux fleet. go-isatty demoted back to an indirect dep.
This commit is contained in:
shoemoney 2026-06-23 10:47:46 -05:00
parent 051341bcf9
commit 4734d674b0
2 changed files with 7 additions and 5 deletions

View file

@ -3,8 +3,8 @@ package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"os"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"git.shoemoney.ai/shoemoney/devbox/internal/config" "git.shoemoney.ai/shoemoney/devbox/internal/config"
@ -58,11 +58,13 @@ func daemonHint(err error) error {
// isTTY reports whether the command's stdout is an interactive terminal. Used to // isTTY reports whether the command's stdout is an interactive terminal. Used to
// decide whether status may show the human-only "(live)" enrichment — piped // decide whether status may show the human-only "(live)" enrichment — piped
// output stays byte-identical to v1 so scripts are unaffected. // output stays byte-identical to v1 so scripts are unaffected. ponytail: stdlib
// ModeCharDevice over a go-isatty dep; the fleet is mac/Linux, Cygwin is moot.
func isTTY(cmd *cobra.Command) bool { func isTTY(cmd *cobra.Command) bool {
f, ok := cmd.OutOrStdout().(interface{ Fd() uintptr }) f, ok := cmd.OutOrStdout().(*os.File)
if !ok { if !ok {
return false return false
} }
return isatty.IsTerminal(f.Fd()) || isatty.IsCygwinTerminal(f.Fd()) fi, err := f.Stat()
return err == nil && fi.Mode()&os.ModeCharDevice != 0
} }

2
go.mod
View file

@ -6,7 +6,6 @@ require (
github.com/BurntSushi/toml v1.6.0 github.com/BurntSushi/toml v1.6.0
github.com/fsnotify/fsnotify v1.10.1 github.com/fsnotify/fsnotify v1.10.1
github.com/jotfs/fastcdc-go v0.2.0 github.com/jotfs/fastcdc-go v0.2.0
github.com/mattn/go-isatty v0.0.20
github.com/spf13/cobra v1.10.2 github.com/spf13/cobra v1.10.2
github.com/zeebo/blake3 v0.2.4 github.com/zeebo/blake3 v0.2.4
golang.org/x/time v0.15.0 golang.org/x/time v0.15.0
@ -18,6 +17,7 @@ require (
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/cpuid/v2 v2.0.12 // indirect github.com/klauspost/cpuid/v2 v2.0.12 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/pflag v1.0.9 // indirect github.com/spf13/pflag v1.0.9 // indirect