summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go25
-rw-r--r--main.go8
2 files changed, 17 insertions, 16 deletions
diff --git a/argv.go b/argv.go
index 0a5a453..67a64d4 100644
--- a/argv.go
+++ b/argv.go
@@ -1,8 +1,9 @@
package main
import (
- "fmt"
"os"
+
+ "go.wit.com/lib/gui/prep"
)
/*
@@ -41,15 +42,19 @@ go-mod-clean will try to verify your go.* files are using the newest package ver
`
}
-func (a args) DoAutoComplete(argv []string) {
- switch argv[0] {
- case "checkout":
- fmt.Println("user devel master ")
- default:
- if argv[0] == ARGNAME {
- // list the subcommands here
- fmt.Println("strict restore purge lax")
- }
+/*
+ handles shell autocomplete
+*/
+
+func (args) Appname() string {
+ return ARGNAME
+}
+
+func (a args) DoAutoComplete(pb *prep.Auto) {
+ if pb.Cmd == "" {
+ pb.Autocomplete3([]string{"strict", "--restore", "purge", "lax"})
+ } else {
+ pb.SubCommand(pb.Argv...)
}
os.Exit(0)
}
diff --git a/main.go b/main.go
index 5fe981c..34094ba 100644
--- a/main.go
+++ b/main.go
@@ -4,7 +4,6 @@ import (
"os"
"strings"
- "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
@@ -18,19 +17,16 @@ var BUILDTIME string
// used for shell auto completion
var ARGNAME string = "go-mod-clean"
-var pp *arg.Parser
+var auto *prep.Auto // more experiments for bash handling
var forge *forgepb.Forge
// var check *gitpb.Repo
var configSave bool
func main() {
+ auto = prep.Bash3(&argv) // add support for bash autocomplete with go-arg // this line must be before anything else
log.Info("go-mod-clean version", VERSION, "built on", BUILDTIME)
- // command line parsing & handling
- prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: make this: prep.Bash(argv)
- pp = arg.MustParse(&argv)
-
forge = forgepb.Init()
// figure out what directory we are running in