diff options
| author | Jeff Carr <[email protected]> | 2025-10-17 15:42:51 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-17 15:42:51 -0500 |
| commit | c78eff62bb86594f71f9ff43ff151820ae8e94d9 (patch) | |
| tree | 3cbf2c08c026d1cd7861c11b54eddbd2cecc6120 | |
| parent | b927a2685791dfabb386f50ad1d1c766341bdb4a (diff) | |
new argv PB code location
| -rw-r--r-- | argv.go | 16 | ||||
| -rw-r--r-- | main.go | 23 |
2 files changed, 26 insertions, 13 deletions
@@ -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...) } @@ -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 |
