mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-17 20:10:24 +00:00
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:
+12
-2
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user