implement AppConfig and refactored AppContext
This commit is contained in:
parent
1874a875f5
commit
796075d9f2
12
main.go
12
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user