summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go1
-rw-r--r--doInput.go56
-rw-r--r--main.go11
3 files changed, 63 insertions, 5 deletions
diff --git a/argv.go b/argv.go
index 3b68ffc..b298ecd 100644
--- a/argv.go
+++ b/argv.go
@@ -14,6 +14,7 @@ type args struct {
Format *EmptyCmd `arg:"subcommand:format" help:"add a conversation"`
Playback *PlaybackCmd `arg:"subcommand:playback" help:"dump your prior conversations to the terminal'"`
Output string `arg:"--output" help:"should get a string from gemini-cli"`
+ Input string `arg:"--input" help:"should get a string from gemini-cli"`
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/doInput.go b/doInput.go
new file mode 100644
index 0000000..3278d36
--- /dev/null
+++ b/doInput.go
@@ -0,0 +1,56 @@
+package main
+
+import (
+ "os"
+ "time"
+
+ "go.wit.com/lib/protobuf/chatpb"
+ "go.wit.com/log"
+ "google.golang.org/protobuf/types/known/timestamppb"
+)
+
+func doInput(s string) {
+ filename := "/tmp/gemini-input.log"
+ f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
+ if err != nil {
+ log.Println(err)
+ return
+ }
+ defer f.Close()
+ if _, err := f.WriteString(s + "\n"); err != nil {
+ log.Println(err)
+ }
+
+ log.Info("INPUT LOGGED TO", filename)
+
+ // Load the existing chats.
+ all := chatpb.NewChats()
+ if err := all.ConfigLoad(); err != nil {
+ log.Warn("Error loading config, can't add to auto chat:", err)
+ return
+ }
+
+ // Find the "auto" chat.
+ var autoChat *chatpb.Chat
+ for _, chat := range all.GetChats() {
+ if chat.GetChatName() == "auto" {
+ autoChat = chat
+ break
+ }
+ }
+
+ // If the "auto" chat is found, add the new entry.
+ if autoChat != nil {
+ newEntry := &chatpb.ChatEntry{
+ From: chatpb.Who_USER,
+ Content: s,
+ Ctime: timestamppb.New(time.Now()),
+ }
+ autoChat.Entries = append(autoChat.Entries, newEntry)
+ if err := all.ConfigSave(); err != nil {
+ log.Warn("Error saving config after adding to auto chat:", err)
+ } else {
+ log.Info("Added new entry to 'auto' chat.")
+ }
+ }
+}
diff --git a/main.go b/main.go
index 9e1daa2..2db5380 100644
--- a/main.go
+++ b/main.go
@@ -58,6 +58,11 @@ func main() {
okExit("")
}
+ if argv.Input != "" {
+ doInput(argv.Input)
+ okExit("")
+ }
+
if argv.Add != "" {
newChats, err := addFile(argv.Add)
if err != nil {
@@ -83,12 +88,8 @@ func main() {
okExit("")
}
- log.Info("trying chatpb")
- pb := chatpb.ExampleChat()
- pb.ConfigSave()
-
// if opening the GUI, always check git for dirty repos
- log.Info("open the gui here")
+ log.Info("look for 'auto' here")
// doGui()
okExit("")
}