feat: add config opt-out, TTY check, and config-first update flow

- Add auto_update_check config field (defaults to true)
- Load config before update check, skip if auto_update_check is false
- Add TTY check before interactive prompt (skip in non-TTY environments)
- Update config.example.yaml with new option documentation
This commit is contained in:
2026-08-22 10:44:01 +02:00
parent 7f2c9b2ba8
commit c0ad7e803e
5 changed files with 35 additions and 2 deletions
+12 -2
View File
@@ -83,8 +83,18 @@ func main() {
}
}
if checkForUpdateInteractive(verbose) {
os.Exit(0)
// Load config early to check auto_update_update and validate.
cfgPath, err := config.DefaultPath()
if err == nil {
cfg, cfgErr := config.Load(cfgPath)
if cfgErr != nil {
fmt.Fprintf(os.Stderr, "WARNING: failed to load config: %v\n", cfgErr)
}
if cfgErr == nil && cfg.IsAutoUpdateCheckEnabled() {
if checkForUpdateInteractive(verbose) {
os.Exit(0)
}
}
}
m := newFullModel()
+5
View File
@@ -13,6 +13,7 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/creativeprojects/go-selfupdate"
"golang.org/x/term"
)
const (
@@ -88,6 +89,10 @@ func checkForUpdateInteractive(verbose bool) bool {
return false
}
if !term.IsTerminal(int(os.Stdin.Fd())) {
return false
}
updater, err := initUpdater(verbose)
if err != nil {
if verbose {