use an auto complete PB

This commit is contained in:
Jeff Carr 2025-09-17 17:03:43 -05:00
parent ce0fd10064
commit b8252f5caa
1 changed files with 16 additions and 15 deletions

31
argv.go
View File

@ -6,7 +6,8 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"go.wit.com/lib/gui/prep"
) )
/* /*
@ -152,13 +153,13 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
// handles shell autocomplete // handles shell autocomplete
// //
func DoAutoComplete(arg0 string, arg1 string, argv []string) { // arg0 should be the last entry
if strings.HasPrefix(argv[0], "-") { // arg1 should be the 'current' thing the user is typing
fmt.Fprintf(os.Stderr, "stuff --gui --all '%s' '%s' %v\n", arg0, arg1, argv) // it should be '' if the user doesn't have a partial string to match
fmt.Println("--all --gui") func DoAutoComplete(autoArgv *prep.Auto) {
return fmt.Fprintf(os.Stderr, "stuff --gui --all '%s' '%s' %v\n", autoArgv.Arg0, autoArgv.Arg1, autoArgv.Argv)
}
switch argv[0] { switch autoArgv.Argv[0] {
case "checkout": case "checkout":
fmt.Println("devel master user") fmt.Println("devel master user")
case "clean": case "clean":
@ -174,7 +175,7 @@ func DoAutoComplete(arg0 string, arg1 string, argv []string) {
case "dirty": case "dirty":
fmt.Println("") fmt.Println("")
case "gui": case "gui":
if ifBlank(argv[1]) { if autoArgv.Partial == "" {
fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, "CUI: terminal interface using 'gocui'") fmt.Fprintln(os.Stderr, "CUI: terminal interface using 'gocui'")
fmt.Fprintln(os.Stderr, "GUI: linux and macos GUI using GTK") fmt.Fprintln(os.Stderr, "GUI: linux and macos GUI using GTK")
@ -204,10 +205,10 @@ func DoAutoComplete(arg0 string, arg1 string, argv []string) {
case "tag": case "tag":
fmt.Println("list --delete clean") fmt.Println("list --delete clean")
default: default:
if argv[0] == ARGNAME { // if argv.ArgName == ARGNAME {
// list the subcommands here // }
fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui") // list the subcommands here
} fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui")
} }
os.Exit(0) os.Exit(0)
} }
@ -220,6 +221,6 @@ func ifBlank(arg string) bool {
return false return false
} }
func (a args) DoAutoComplete(arg0 string, arg1 string, argv []string) { func (a args) DoAutoComplete(autoArgv *prep.Auto) {
DoAutoComplete(arg0, arg1, argv) DoAutoComplete(autoArgv)
} }