Первая версия (CLI-only) #1
@@ -40,6 +40,7 @@ type AppConfig struct {
|
||||
SettingsReviewed bool `mapstructure:"settings_reviewed"`
|
||||
EnableAlarm bool `mapstructure:"enable_alarm"`
|
||||
EnableLinkOpening bool `mapstructure:"enable_link_opening"`
|
||||
LinksToOpenCount int `mapstructure:"links_to_open_count"`
|
||||
UseAttendanceJounralApi bool `mapstructure:"use_attendance_journal_api"`
|
||||
UseCustomBrowserCommand bool `mapstructure:"use_custom_browser_command"`
|
||||
BrowserOpenCommand string `mapstructure:"browser_open_command"`
|
||||
@@ -79,6 +80,7 @@ func getDefaultConfig() Config {
|
||||
SettingsReviewed: false,
|
||||
EnableAlarm: false,
|
||||
EnableLinkOpening: true,
|
||||
LinksToOpenCount: 5,
|
||||
UseAttendanceJounralApi: false,
|
||||
UseCustomBrowserCommand: false,
|
||||
BrowserOpenCommand: "firefox %s",
|
||||
@@ -86,12 +88,17 @@ func getDefaultConfig() Config {
|
||||
},
|
||||
Screenshot: ScreenshotConfig{
|
||||
ScreenIndex: 0,
|
||||
Interval: 5,
|
||||
Interval: 2,
|
||||
Directory: getTempDirectoryPath(),
|
||||
BufferCount: 5,
|
||||
},
|
||||
Communication: CommunicationConfig{
|
||||
QrUrl: "",
|
||||
QrQueryToken: "",
|
||||
ApiSelfApproveMethod: "",
|
||||
},
|
||||
Logging: LoggingConfig{
|
||||
Level: "info",
|
||||
Level: "debug",
|
||||
Output: "stdout",
|
||||
},
|
||||
Telemetry: TelemetryConfig{
|
||||
@@ -133,6 +140,7 @@ func initializeViper(appName string) (*viper.Viper, string, error) {
|
||||
v.SetDefault("app.settings_reviewed", defaults.App.SettingsReviewed)
|
||||
v.SetDefault("app.enable_alarm", defaults.App.EnableAlarm)
|
||||
v.SetDefault("app.enable_link_opening", defaults.App.EnableLinkOpening)
|
||||
v.SetDefault("app.links_to_open_count", defaults.App.LinksToOpenCount)
|
||||
v.SetDefault("app.use_attendance_journal_api", defaults.App.UseAttendanceJounralApi)
|
||||
v.SetDefault("app.use_custom_browser_command", defaults.App.UseCustomBrowserCommand)
|
||||
v.SetDefault("app.browser_open_command", defaults.App.BrowserOpenCommand)
|
||||
@@ -143,6 +151,11 @@ func initializeViper(appName string) (*viper.Viper, string, error) {
|
||||
v.SetDefault("screenshot.directory", defaults.Screenshot.Directory)
|
||||
v.SetDefault("screenshot.buffer_count", defaults.Screenshot.BufferCount)
|
||||
|
||||
// Set empty string defaults for communication parameters
|
||||
v.SetDefault("communication.self_approve_url", defaults.Communication.QrUrl)
|
||||
v.SetDefault("communication.qr_query_token", defaults.Communication.QrQueryToken)
|
||||
v.SetDefault("communication.api_self_approve_method", defaults.Communication.ApiSelfApproveMethod)
|
||||
|
||||
v.SetDefault("logging.level", defaults.Logging.Level)
|
||||
v.SetDefault("logging.output", defaults.Logging.Output)
|
||||
|
||||
@@ -161,6 +174,7 @@ func (c *Config) Save() error {
|
||||
v.Set("app.settings_reviewed", c.App.SettingsReviewed)
|
||||
v.Set("app.enable_alarm", c.App.EnableAlarm)
|
||||
v.Set("app.enable_link_opening", c.App.EnableLinkOpening)
|
||||
v.Set("app.links_to_open_count", c.App.LinksToOpenCount)
|
||||
v.Set("app.use_attendance_journal_api", c.App.UseAttendanceJounralApi)
|
||||
v.Set("app.use_custom_browser_command", c.App.UseCustomBrowserCommand)
|
||||
v.Set("app.browser_open_command", c.App.BrowserOpenCommand)
|
||||
@@ -171,22 +185,17 @@ func (c *Config) Save() error {
|
||||
v.Set("screenshot.directory", c.Screenshot.Directory)
|
||||
v.Set("screenshot.buffer_count", c.Screenshot.BufferCount)
|
||||
|
||||
// Always set communication parameters, even if empty
|
||||
v.Set("communication.self_approve_url", c.Communication.QrUrl)
|
||||
v.Set("communication.qr_query_token", c.Communication.QrQueryToken)
|
||||
v.Set("communication.api_self_approve_method", c.Communication.ApiSelfApproveMethod)
|
||||
|
||||
v.Set("logging.level", c.Logging.Level)
|
||||
v.Set("logging.output", c.Logging.Output)
|
||||
|
||||
v.Set("telemetry.enable_statistics_collection", c.Telemetry.EnableStatisticsCollection)
|
||||
v.Set("telemetry.enable_anonymous_error_reports", c.Telemetry.EnableAnonymousErrorReports)
|
||||
|
||||
if c.Communication.QrUrl != "" {
|
||||
v.Set("communication.self_approve_url", c.Communication.QrUrl)
|
||||
}
|
||||
if c.Communication.QrQueryToken != "" {
|
||||
v.Set("communication.qr_query_token", c.Communication.QrQueryToken)
|
||||
}
|
||||
if c.Communication.ApiSelfApproveMethod != "" {
|
||||
v.Set("communication.api_self_approve_method", c.Communication.ApiSelfApproveMethod)
|
||||
}
|
||||
|
||||
return v.WriteConfig()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user