use an auto complete PB
This commit is contained in:
parent
ce0fd10064
commit
b8252f5caa
31
argv.go
31
argv.go
|
@ -6,7 +6,8 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"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
|
||||
//
|
||||
|
||||
func DoAutoComplete(arg0 string, arg1 string, argv []string) {
|
||||
if strings.HasPrefix(argv[0], "-") {
|
||||
fmt.Fprintf(os.Stderr, "stuff --gui --all '%s' '%s' %v\n", arg0, arg1, argv)
|
||||
fmt.Println("--all --gui")
|
||||
return
|
||||
}
|
||||
switch argv[0] {
|
||||
// arg0 should be the last entry
|
||||
// arg1 should be the 'current' thing the user is typing
|
||||
// it should be '' if the user doesn't have a partial string to match
|
||||
func DoAutoComplete(autoArgv *prep.Auto) {
|
||||
fmt.Fprintf(os.Stderr, "stuff --gui --all '%s' '%s' %v\n", autoArgv.Arg0, autoArgv.Arg1, autoArgv.Argv)
|
||||
|
||||
switch autoArgv.Argv[0] {
|
||||
case "checkout":
|
||||
fmt.Println("devel master user")
|
||||
case "clean":
|
||||
|
@ -174,7 +175,7 @@ func DoAutoComplete(arg0 string, arg1 string, argv []string) {
|
|||
case "dirty":
|
||||
fmt.Println("")
|
||||
case "gui":
|
||||
if ifBlank(argv[1]) {
|
||||
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")
|
||||
|
@ -204,10 +205,10 @@ func DoAutoComplete(arg0 string, arg1 string, argv []string) {
|
|||
case "tag":
|
||||
fmt.Println("list --delete clean")
|
||||
default:
|
||||
if argv[0] == ARGNAME {
|
||||
// list the subcommands here
|
||||
fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui")
|
||||
}
|
||||
// if argv.ArgName == ARGNAME {
|
||||
// }
|
||||
// list the subcommands here
|
||||
fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui")
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
@ -220,6 +221,6 @@ func ifBlank(arg string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (a args) DoAutoComplete(arg0 string, arg1 string, argv []string) {
|
||||
DoAutoComplete(arg0, arg1, argv)
|
||||
func (a args) DoAutoComplete(autoArgv *prep.Auto) {
|
||||
DoAutoComplete(autoArgv)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue