more code cleanups

This commit is contained in:
Jeff Carr 2025-08-30 15:24:54 -05:00
parent c7896e47f9
commit bbb12d79e2
3 changed files with 27 additions and 7 deletions

View File

@ -25,8 +25,9 @@ type EmptyCmd struct {
}
type PlaybackCmd struct {
List *EmptyCmd `arg:"subcommand:list" help:"list memories"`
Long *EmptyCmd `arg:"subcommand:long" help:"show info on each chat"`
List *EmptyCmd `arg:"subcommand:list" help:"list memories"`
Long *EmptyCmd `arg:"subcommand:long" help:"show info on each chat"`
Purge *EmptyCmd `arg:"subcommand:purge" help:"verify chat uuids & purge empty chats"`
}
func (args) Version() string {

View File

@ -24,7 +24,7 @@ func (args) doBashAuto() {
// argv.doBashHelp()
switch argv.BashAuto[0] {
case "playback":
fmt.Println("long --uuid")
fmt.Println("long --uuid purge")
case "clean":
fmt.Println("user devel master")
default:

View File

@ -7,13 +7,32 @@ import (
"go.wit.com/log"
)
func doPlayback() {
func doPlayback() error {
if argv.Uuid != "" {
showChat(argv.Uuid)
return
return nil
}
if argv.Playback.Purge != nil {
doPurge()
return nil
}
listChats(me.chats)
return nil
}
func doPurge() {
changed := false
for _, chat := range me.chats.GetChats() {
if len(chat.GetEntries()) == 0 {
me.chats.Delete(chat)
changed = true
}
}
if changed {
me.chats.ConfigSave()
}
}
func showChat(uuid string) {
@ -46,11 +65,11 @@ func listChats(chats *chatpb.Chats) {
formattedTime = "No Timestamp"
}
log.Printf("Topic: %-25s | Entries: %-4d | Started: %s | UUID: %s\n",
chat.GetChatName(),
log.Printf("Entries: %-4d | Started: %-25s | UUID: %s | %-25s\n",
entryCount,
formattedTime,
chat.GetUuid(),
chat.GetChatName(),
)
}
log.Println("-------------------------------------------------")