summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go2
-rw-r--r--doCountAuto.go16
-rw-r--r--doNewChat.go28
-rw-r--r--main.go10
4 files changed, 56 insertions, 0 deletions
diff --git a/argv.go b/argv.go
index 21c6210..775b0b5 100644
--- a/argv.go
+++ b/argv.go
@@ -17,6 +17,8 @@ type args struct {
Input string `arg:"--input" help:"should get a string from regex-cli"`
ImportFile string `arg:"--import" help:"import a file from regex-cli"`
Stats []string `arg:"--stats" help:"add stats to a chat"`
+ NewChat []string `arg:"--new-chat" help:"create a new chat"`
+ CountAuto bool `arg:"--count-auto" help:"count the number of auto chats"`
Force bool `arg:"--force" help:"try to strong arm things"`
Verbose bool `arg:"--verbose" help:"show more output"`
Bash bool `arg:"--bash" help:"generate bash completion"`
diff --git a/doCountAuto.go b/doCountAuto.go
new file mode 100644
index 0000000..2aa958e
--- /dev/null
+++ b/doCountAuto.go
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "fmt"
+ "strings"
+)
+
+func doCountAuto() {
+ count := 0
+ for _, chat := range me.chats.GetChats() {
+ if strings.HasPrefix(chat.GetChatName(), "Auto ") {
+ count++
+ }
+ }
+ fmt.Println(count)
+}
diff --git a/doNewChat.go b/doNewChat.go
new file mode 100644
index 0000000..bd71f45
--- /dev/null
+++ b/doNewChat.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "fmt"
+
+ "go.wit.com/lib/protobuf/chatpb"
+ "go.wit.com/log"
+ "google.golang.org/protobuf/types/known/timestamppb"
+)
+
+func doNewChat() {
+ if len(argv.NewChat) != 2 {
+ log.Error(fmt.Errorf("expected 2 arguments for --new-chat"))
+ return
+ }
+ uuid := argv.NewChat[0]
+ topic := argv.NewChat[1]
+
+ chat := &chatpb.Chat{
+ Uuid: uuid,
+ ChatName: topic,
+ Ctime: timestamppb.Now(),
+ }
+
+ me.chats.Chats = append(me.chats.Chats, chat)
+ me.chats.ConfigSave()
+ log.Info("created new chat for", uuid)
+}
diff --git a/main.go b/main.go
index c0dbf79..57c91e2 100644
--- a/main.go
+++ b/main.go
@@ -53,6 +53,16 @@ func main() {
me.chats.ConfigSave()
}
+ if argv.CountAuto {
+ doCountAuto()
+ okExit("")
+ }
+
+ if argv.NewChat != nil {
+ doNewChat()
+ okExit("")
+ }
+
if argv.Stats != nil {
doStats()
okExit("")