From 796075d9f29bb3b4b9e380e37632d7dc5e03c8ac Mon Sep 17 00:00:00 2001 From: agatha Date: Sun, 12 May 2024 15:54:36 -0400 Subject: [PATCH] implement AppConfig and refactored AppContext --- main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 92d455d..aec2609 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" + "ketotrack/config" "ketotrack/data" "ketotrack/model" ) @@ -38,9 +39,14 @@ func init() { } func main() { - var appCtx data.AppContext + appConfig := config.Load() + appCtx, err := data.NewContext(appConfig.DataPath) + if err != nil { + fmt.Printf("Error initializing application context: %s\n", err) + return + } - if err := appCtx.LoadRecords(recordsFilename); err != nil { + if err := appCtx.LoadRecords(); err != nil { fmt.Printf("Error loading records from file: %s\n", err) } @@ -79,7 +85,7 @@ func main() { } // Save Records before exiting - if err := appCtx.SaveRecords(recordsFilename); err != nil { + if err := appCtx.SaveRecords(); err != nil { fmt.Printf("Error saving records to file: %s\n", err) } }