From c78eff62bb86594f71f9ff43ff151820ae8e94d9 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 17 Oct 2025 15:42:51 -0500 Subject: new argv PB code location --- argv.go | 16 +++++++++------- main.go | 23 +++++++++++++++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/argv.go b/argv.go index 77f7690..f7ed4f0 100644 --- a/argv.go +++ b/argv.go @@ -3,7 +3,7 @@ package main import ( "os" - "go.wit.com/lib/gui/prep" + "go.wit.com/lib/protobuf/argvpb" ) /* @@ -27,10 +27,6 @@ type args struct { type EmptyCmd struct { } -func (args) Version() string { - return "go-mod-clean " + VERSION + " Built on " + BUILDTIME -} - func (a args) Description() string { return ` go-mod-clean will try to verify your go.* files are using the newest package versions @@ -54,9 +50,15 @@ func (args) Buildtime() (string, string) { return BUILDTIME, VERSION } -func (a args) DoAutoComplete(pb *prep.Auto) { +func (args) Version() string { + return argvpb.StandardVersion(ARGNAME, VERSION, BUILDTIME) +} + +// sends the strings to bash or zsh that will be your options +func (a args) SendCompletionStrings(pb *argvpb.Argv) { if pb.Cmd == "" { - pb.Autocomplete3([]string{"strict", "--restore", "purge", "lax", "--version"}) + base := []string{"strict", "--restore", "purge", "lax", "--version"} + pb.SendStrings(base) } else { pb.SubCommand(pb.Goargs...) } diff --git a/main.go b/main.go index d4f772f..c0f0c65 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,8 @@ package main import ( "os" - "go.wit.com/lib/gui/prep" + "go.wit.com/lib/gui/shell" + "go.wit.com/lib/protobuf/argvpb" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" @@ -16,15 +17,14 @@ var BUILDTIME string // used for shell auto completion var ARGNAME string = "go-mod-clean" -var auto *prep.Auto // more experiments for bash handling +var newargv *argvpb.Argv // more experiments for bash handling var forge *forgepb.Forge // var check *gitpb.Repo var configSave bool func main() { - auto = prep.Bash(&argv) // add support for bash autocomplete with go-arg // this line must be before anything else - log.Info(auto.Version()) + newargv = argvpb.Autocomplete(&argv) // adds shell auto complete to go-args forge, _ = forgepb.Init() @@ -32,8 +32,19 @@ func main() { pwd, _ := os.Getwd() check := forge.Repos.FindByFullPath(pwd) if check == nil { - log.Info("this directory isn't in a golang project (not in ~/go/src nor a go.work file)") - badExit(nil, nil) + log.Info("the forge code isn't working right. couldn't figure out path:", pwd) + // just run "go mod init" and "go mod tidy" + var err error + _, err = shell.RunVerbose([]string{"go", "mod", "init"}) + if err != nil { + badExit(nil, nil) + } + _, err = shell.RunVerbose([]string{"go", "mod", "tidy"}) + if err != nil { + badExit(nil, nil) + } + log.Info("todo: check return values here in go-mod-clean") + newargv.GoodExit("may have worked somewhat") // exits back to the shell via argv (with timing) } // deletes all the git notes -- cgit v1.2.3