summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-30 15:24:54 -0500
committerJeff Carr <[email protected]>2025-08-30 15:24:54 -0500
commitbbb12d79e2ab03d5dd5a781a5e3b1192c548721e (patch)
tree4f7a152f1e14f9d181c9e9614925a5184381f187
parentc7896e47f9c91e330b023bdb34a7540f193a5422 (diff)
more code cleanups
-rw-r--r--argv.go5
-rw-r--r--argvAutoshell.go2
-rw-r--r--doPlayback.go27
3 files changed, 27 insertions, 7 deletions
diff --git a/argv.go b/argv.go
index e6c4c0b..375ca06 100644
--- a/argv.go
+++ b/argv.go
@@ -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 {
diff --git a/argvAutoshell.go b/argvAutoshell.go
index 3611411..14a21f1 100644
--- a/argvAutoshell.go
+++ b/argvAutoshell.go
@@ -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:
diff --git a/doPlayback.go b/doPlayback.go
index 42dd95d..2302d12 100644
--- a/doPlayback.go
+++ b/doPlayback.go
@@ -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("-------------------------------------------------")