feat: add tabbed settings dialog
This commit is contained in:
@@ -8,22 +8,28 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
CheckAUR bool `json:"check_aur"`
|
||||
ReminderIntervalHours int `json:"reminder_interval_hours"`
|
||||
Terminal string `json:"terminal"`
|
||||
AutoRefreshMinutes int `json:"auto_refresh_minutes"`
|
||||
ShowIgnored bool `json:"show_ignored"`
|
||||
IgnoredPackages []string `json:"ignored_packages"`
|
||||
CheckAUR bool `json:"check_aur"`
|
||||
ReminderIntervalHours int `json:"reminder_interval_hours"`
|
||||
Terminal string `json:"terminal"`
|
||||
AutoRefreshMinutes int `json:"auto_refresh_minutes"`
|
||||
ShowIgnored bool `json:"show_ignored"`
|
||||
NotificationsEnabled bool `json:"notifications_enabled"`
|
||||
KeepTerminalOpen bool `json:"keep_terminal_open"`
|
||||
ConfirmSelectedInstalls bool `json:"confirm_selected_installs"`
|
||||
IgnoredPackages []string `json:"ignored_packages"`
|
||||
}
|
||||
|
||||
func Default() Config {
|
||||
return Config{
|
||||
CheckAUR: true,
|
||||
ReminderIntervalHours: 168,
|
||||
Terminal: "auto",
|
||||
AutoRefreshMinutes: 30,
|
||||
ShowIgnored: false,
|
||||
IgnoredPackages: []string{},
|
||||
CheckAUR: true,
|
||||
ReminderIntervalHours: 168,
|
||||
Terminal: "auto",
|
||||
AutoRefreshMinutes: 30,
|
||||
ShowIgnored: false,
|
||||
NotificationsEnabled: true,
|
||||
KeepTerminalOpen: true,
|
||||
ConfirmSelectedInstalls: true,
|
||||
IgnoredPackages: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +43,25 @@ func Load(path string) (Config, error) {
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
var raw map[string]json.RawMessage
|
||||
if err := json.Unmarshal(data, &raw); err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
if err := json.Unmarshal(data, &cfg); err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
defaults := Default()
|
||||
if _, ok := raw["notifications_enabled"]; !ok {
|
||||
cfg.NotificationsEnabled = defaults.NotificationsEnabled
|
||||
}
|
||||
if _, ok := raw["keep_terminal_open"]; !ok {
|
||||
cfg.KeepTerminalOpen = defaults.KeepTerminalOpen
|
||||
}
|
||||
if _, ok := raw["confirm_selected_installs"]; !ok {
|
||||
cfg.ConfirmSelectedInstalls = defaults.ConfirmSelectedInstalls
|
||||
}
|
||||
|
||||
cfg = normalize(cfg)
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user