diff options
| author | Castor Gemini <[email protected]> | 2025-08-22 03:45:34 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-22 03:45:34 -0500 |
| commit | 8f9726c6e47c2c722137f2d2aabe4c507ece5c14 (patch) | |
| tree | 455a79ffd84900002f96d46f084ec4646f3c5444 /main.go | |
| parent | 73bc0f73aa03d521d18e3cb64b8550db5c801e32 (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.go | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -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("") } |
