From 5e8fab62dc79d50e1d4b447db9f6a70bcd14da42 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 25 Sep 2025 02:30:52 -0500 Subject: [PATCH] new argv bash completion --- argv.go | 23 +++++++++++------------ build | 4 ++++ main.go | 6 ++---- structs.go | 3 +-- 4 files changed, 18 insertions(+), 18 deletions(-) create mode 100755 build diff --git a/argv.go b/argv.go index 5af91c9..29c3ec0 100644 --- a/argv.go +++ b/argv.go @@ -4,8 +4,9 @@ package main import ( - "fmt" "os" + + "go.wit.com/lib/gui/prep" ) /* @@ -58,17 +59,15 @@ regex -- interact with Googles' Gemini AI handles shell autocomplete */ -func (a args) DoAutoComplete(argv []string) { - switch argv[0] { - case "playback": - fmt.Println("long --uuid purge last submit") - case "clean": - fmt.Println("") - default: - if argv[0] == ARGNAME { - // list the subcommands here - fmt.Println("--json interact playback clean") - } +func (args) Appname() string { + return ARGNAME +} + +func (a args) DoAutoComplete(pb *prep.Auto) { + if pb.Cmd == "" { + pb.Autocomplete3([]string{"--bash", "interact", "playback", "clean"}) + } else { + pb.SubCommand(pb.Argv...) } os.Exit(0) } diff --git a/build b/build new file mode 100755 index 0000000..2bcc277 --- /dev/null +++ b/build @@ -0,0 +1,4 @@ +#!/bin/bash -x + +mkdir -p files/usr/share/bash-completion/completions/ +regex --bash > files/usr/share/bash-completion/completions/regex diff --git a/main.go b/main.go index e85db7b..42ec96f 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "embed" "github.com/google/uuid" - "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/chatpb" "go.wit.com/log" @@ -32,9 +31,8 @@ var configSave bool func main() { me = new(mainType) - prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv) - me.myGui = prep.Gui() // prepares the GUI package for go-args - me.pp = arg.MustParse(&argv) + me.myGui = prep.Gui() // prepares the GUI package for go-args + me.auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg var err error // load the default chat protobuf diff --git a/structs.go b/structs.go index fac6ee5..21a527c 100644 --- a/structs.go +++ b/structs.go @@ -6,7 +6,6 @@ package main import ( "context" - "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/chatpb" @@ -17,7 +16,7 @@ var me *mainType // this app's variables type mainType struct { - pp *arg.Parser // for parsing the command line args. Yay to alexf lint! + auto *prep.Auto // more experiments for bash handling chats *chatpb.Chats // all our prior conversations with regex client *genai.Client // the Google Gemini AI client variable ctx context.Context // global context. what does this acutally mean?