summaryrefslogtreecommitdiff
path: root/doPlayback.go
blob: 9ece30ea8bf55bfd2b51d93001f928e84cc7377e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main

import (
	"fmt"

	"go.wit.com/log"
)

func doPlayback() {
	if argv.Playback.Uuid != "" {
		showChat(argv.Playback.Uuid)
		return
	}

	log.Infof("Found %d chat topic(s) in the log.", len(me.chats.GetChats()))
	fmt.Println("-------------------------------------------------")

	for _, chat := range me.chats.GetChats() {
		entryCount := len(chat.GetEntries())
		var formattedTime string
		if ctime := chat.GetCtime(); ctime != nil {
			t := ctime.AsTime()
			formattedTime = t.Format("2006-01-02 15:04:05")
		} else {
			formattedTime = "No Timestamp"
		}

		fmt.Printf("Topic: %-25s | Entries: %-4d | Started: %s | UUID: %s\n",
			chat.GetChatName(),
			entryCount,
			formattedTime,
			chat.GetUuid(),
		)
	}
	fmt.Println("-------------------------------------------------")
}

func showChat(uuid string) {
	chat := me.chats.FindByUuid(uuid)
	if chat == nil {
		log.Info("unknown uuid", uuid)
		return
	}
	// Call the new, dedicated formatting function.
	prettyFormatChat(chat)
}