From 2ce32a0f2fb06c94bbb36e11b528093812df4453 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 18 Sep 2025 16:03:11 -0500 Subject: [PATCH] more autocomplete cleanups --- argv.go | 49 +++++++++++++------------------------------------ 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/argv.go b/argv.go index fcc5a91..e1d5222 100644 --- a/argv.go +++ b/argv.go @@ -6,10 +6,8 @@ package main import ( "fmt" "os" - "time" "go.wit.com/lib/gui/prep" - "go.wit.com/lib/gui/shell" ) /* @@ -158,26 +156,10 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. // arg0 should be the last entry // arg1 should be the 'current' thing the user is typing // it should be empty if the user doesn't have a partial string to match -func DoAutoComplete(autoArgv *prep.Auto) { - // autoArgv.FastHelp() - dur := autoArgv.Duration.AsDuration() - if dur < time.Millisecond*200 { - autoArgv.Debug = true - autoArgv.Debugf("TODO: show extended help here '%s' '%s' %v dur=%v\n", autoArgv.Arg0, autoArgv.Arg1, autoArgv.Argv, shell.FormatDuration(dur)) - autoArgv.PrintDebug() - fmt.Println(" ") - } - - switch autoArgv.Cmd { +func DoAutoComplete(pb *prep.Auto) { + switch pb.Cmd { case "checkout": - if dur < time.Millisecond*200 { - // me.pp.WriteHelpForSubcommand(os.Stderr, "checkout") - autoArgv.Debugf("master: checkout the master branches on all repos") - autoArgv.Debugf("devel: checkout the devel branches on all repos") - autoArgv.Debugf("user: checkout the user branches on all repos") - } - // argv.Checkout.Autocomplete("devel master user") - autoArgv.Autocomplete2("devel master user") + pb.Autocomplete2("devel master user") case "clean": // me.pp.WriteHelp(os.Stderr) // me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...) @@ -185,25 +167,19 @@ func DoAutoComplete(autoArgv *prep.Auto) { // me.pp.WriteHelpForSubcommand(os.Stderr, "clean") fmt.Println("--force verify --repo") case "commit": - autoArgv.Autocomplete2("--all") + pb.Autocomplete2("--all") case "config": fmt.Println("add fix list") case "dirty": fmt.Println("") case "gui": - if autoArgv.Partial == "" { - fmt.Fprintln(os.Stderr, "") - fmt.Fprintln(os.Stderr, "CUI: terminal interface using 'gocui'") - fmt.Fprintln(os.Stderr, "GUI: linux and macos GUI using GTK") - } else { - fmt.Println("CUI GUI") - } + fmt.Println("") case "--gui": - fmt.Println("andlabs gocui") + pb.Autocomplete2("andlabs gocui") case "list": - fmt.Println("--mine --favorites --dirty") + pb.Autocomplete2("--mine --favorites --dirty") case "merge": - autoArgv.Autocomplete2("devel master --all") + pb.Autocomplete2("devel master --all") case "normal": fmt.Println("on off") case "pull": @@ -221,10 +197,11 @@ func DoAutoComplete(autoArgv *prep.Auto) { case "tag": fmt.Println("list --delete clean") default: - // if argv.ArgName == ARGNAME { - // } - // list the subcommands here - autoArgv.Autocomplete2("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui") + if pb.Cmd == "" { + pb.Autocomplete2("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui") + } else { + pb.Autocomplete2("todoGenericCmd") + } } os.Exit(0) }