summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorCastor Gemini <[email protected]>2025-08-22 03:45:34 -0500
committerJeff Carr <[email protected]>2025-08-22 03:45:34 -0500
commit8f9726c6e47c2c722137f2d2aabe4c507ece5c14 (patch)
tree455a79ffd84900002f96d46f084ec4646f3c5444 /main.go
parent73bc0f73aa03d521d18e3cb64b8550db5c801e32 (diff)
refactor(add): Create dedicated addFile function
- Move all file reading and content-inlining logic into a new 'addFile' function in its own 'add.go' file. - The main function now calls this to parse a log file and then appends the returned chats to the main session. - This improves separation of concerns and makes the main loop cleaner.
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/main.go b/main.go
index 880c211..7d294f1 100644
--- a/main.go
+++ b/main.go
@@ -54,19 +54,19 @@ func main() {
}
if argv.Add != "" {
- me.chats.AddFile(argv.Add)
-
- // --- Start Diagnostic Check ---
- // This loop will check for nil entries in the slice before marshaling.
- for i, chat := range me.chats.GetChats() {
- if chat == nil {
- log.Fatalf("Found a nil *Chat pointer at index %d before calling ConfigSave(). This is the cause of the panic.", i)
- }
+ newChats, err := addFile(argv.Add)
+ if err != nil {
+ badExit(err)
+ }
+ for _, newChat := range newChats.GetChats() {
+ me.chats.AppendByUuid(newChat)
}
- log.Info("Sanity check passed: No nil entries found in the Chats slice.")
- // --- End Diagnostic Check ---
- me.chats.ConfigSave()
+ // The verifyUuids function should be run on the main chats object
+ // after adding the new chats.
+ if verifyUuids(me.chats) {
+ me.chats.ConfigSave()
+ }
okExit("")
}