more autocomplete cleanups

This commit is contained in:
Jeff Carr 2025-09-18 16:03:11 -05:00
parent 4d4dcf31cb
commit 2ce32a0f2f
1 changed files with 13 additions and 36 deletions

49
argv.go
View File

@ -6,10 +6,8 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"time"
"go.wit.com/lib/gui/prep" "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 // arg0 should be the last entry
// arg1 should be the 'current' thing the user is typing // 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 // it should be empty if the user doesn't have a partial string to match
func DoAutoComplete(autoArgv *prep.Auto) { func DoAutoComplete(pb *prep.Auto) {
// autoArgv.FastHelp() switch pb.Cmd {
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 {
case "checkout": case "checkout":
if dur < time.Millisecond*200 { pb.Autocomplete2("devel master user")
// 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")
case "clean": case "clean":
// me.pp.WriteHelp(os.Stderr) // me.pp.WriteHelp(os.Stderr)
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...) // me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
@ -185,25 +167,19 @@ func DoAutoComplete(autoArgv *prep.Auto) {
// me.pp.WriteHelpForSubcommand(os.Stderr, "clean") // me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
fmt.Println("--force verify --repo") fmt.Println("--force verify --repo")
case "commit": case "commit":
autoArgv.Autocomplete2("--all") pb.Autocomplete2("--all")
case "config": case "config":
fmt.Println("add fix list") fmt.Println("add fix list")
case "dirty": case "dirty":
fmt.Println("") fmt.Println("")
case "gui": case "gui":
if autoArgv.Partial == "" { fmt.Println("")
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")
}
case "--gui": case "--gui":
fmt.Println("andlabs gocui") pb.Autocomplete2("andlabs gocui")
case "list": case "list":
fmt.Println("--mine --favorites --dirty") pb.Autocomplete2("--mine --favorites --dirty")
case "merge": case "merge":
autoArgv.Autocomplete2("devel master --all") pb.Autocomplete2("devel master --all")
case "normal": case "normal":
fmt.Println("on off") fmt.Println("on off")
case "pull": case "pull":
@ -221,10 +197,11 @@ func DoAutoComplete(autoArgv *prep.Auto) {
case "tag": case "tag":
fmt.Println("list --delete clean") fmt.Println("list --delete clean")
default: default:
// if argv.ArgName == ARGNAME { if pb.Cmd == "" {
// } pb.Autocomplete2("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui")
// list the subcommands here } else {
autoArgv.Autocomplete2("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui") pb.Autocomplete2("todoGenericCmd")
}
} }
os.Exit(0) os.Exit(0)
} }