mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-03-14 03:41:27 +01:00
feat: add --no-update-check flag and disable update check via config (issue #23)
Add support for disabling the automatic update check at startup, which could cause delays on air-gapped or offline machines due to DNS timeouts. - Add --no-update-check CLI flag for one-time override - Add check_for_updates field (*bool) to AppConfig with default true - CLI flag overrides the config file setting (both feed into IsUpdateCheckEnabled) - Move update check from --version template to TUI Init() only, respecting the new configuration - Remove getVersionWithUpdateCheck() from cmd/root.go; --version now prints a plain version string - Rename internal/config/keybindings.go → appconfig.go and keybindings_test.go → appconfig_test.go to reflect the broader scope of the file - Add TestIsUpdateCheckEnabled with table-driven cases (nil config, nil field, true, false) and extend existing integration test with a CheckForUpdates round-trip - Update README: document --no-update-check flag, config option, and rename "Custom Key Bindings" section to "Application Configuration"
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
// NewModel creates a new TUI model with the given SSH hosts
|
||||
func NewModel(hosts []config.SSHHost, configFile string, searchMode bool, currentVersion string) Model {
|
||||
func NewModel(hosts []config.SSHHost, configFile string, searchMode bool, currentVersion string, noUpdateCheck bool) Model {
|
||||
// Load application configuration
|
||||
appConfig, err := config.LoadAppConfig()
|
||||
if err != nil {
|
||||
@@ -26,6 +26,12 @@ func NewModel(hosts []config.SSHHost, configFile string, searchMode bool, curren
|
||||
appConfig = &defaultConfig
|
||||
}
|
||||
|
||||
// CLI flag overrides config file setting
|
||||
if noUpdateCheck {
|
||||
f := false
|
||||
appConfig.CheckForUpdates = &f
|
||||
}
|
||||
|
||||
// Initialize the history manager
|
||||
historyManager, err := history.NewHistoryManager()
|
||||
if err != nil {
|
||||
@@ -151,8 +157,8 @@ func NewModel(hosts []config.SSHHost, configFile string, searchMode bool, curren
|
||||
}
|
||||
|
||||
// RunInteractiveMode starts the interactive TUI interface
|
||||
func RunInteractiveMode(hosts []config.SSHHost, configFile string, searchMode bool, currentVersion string) error {
|
||||
m := NewModel(hosts, configFile, searchMode, currentVersion)
|
||||
func RunInteractiveMode(hosts []config.SSHHost, configFile string, searchMode bool, currentVersion string, noUpdateCheck bool) error {
|
||||
m := NewModel(hosts, configFile, searchMode, currentVersion, noUpdateCheck)
|
||||
|
||||
// Start the application in alt screen mode for clean output
|
||||
p := tea.NewProgram(m, tea.WithAltScreen())
|
||||
|
||||
Reference in New Issue
Block a user