diff --git a/argv.go b/argv.go index 6b25419..70f497a 100644 --- a/argv.go +++ b/argv.go @@ -36,8 +36,6 @@ type args struct { BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"` Force bool `arg:"--force" help:"try to strong arm things"` Verbose bool `arg:"--verbose" help:"show more output"` - Bash bool `arg:"--bash" help:"generate bash completion"` - BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"` } type EmptyCmd struct { @@ -148,6 +146,7 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. ` } +/* func (args) doBashHelpDebug() { fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, "hello world") @@ -164,6 +163,7 @@ func (args) doBashHelpDebug() { fmt.Fprintln(os.Stderr, "pull something else", argv.BashAuto, len(argv.BashAuto), p0, p1, p2, p1a, "end", more) fmt.Fprintln(os.Stderr, "") } +*/ /* handles shell autocomplete @@ -177,14 +177,15 @@ func deleteMatch() { fmt.Println("go.wit.com/lib/gui/repostatus todo: need to do this") } -func ifBlank() bool { - if argv.BashAuto[1] == "''" { +func ifBlank(arg string) bool { + if arg == "''" { // if empty, the user has not typed something return true } return false } +/* // prints help to STDERR // TODO: move everything below this to go-args func (args) doBashHelp() { if argv.BashAuto[1] != "''" { @@ -204,9 +205,20 @@ func (args) doBashHelp() { fmt.Fprintln(os.Stderr, "") } -func (args) doBashAuto() { - // argv.doBashHelp() - switch argv.BashAuto[0] { +func (a args) doBashAuto() { + DoAutoComplete(argv.BashAuto) + os.Exit(0) +} +*/ + +func (a args) DoAutoComplete(argv []string) { + DoAutoComplete(argv) +} + +func DoAutoComplete(argv []string) { + // fmt.Fprintln(os.Stderr, "") // these are for debugging + // fmt.Fprintln(os.Stderr, "in autocomplete:", argv) // these are for debugging + switch argv[0] { case "checkout": fmt.Println("devel master user") case "clean": @@ -224,7 +236,7 @@ func (args) doBashAuto() { case "dirty": fmt.Println("") case "gui": - if ifBlank() { + if ifBlank(argv[1]) { fmt.Fprintln(os.Stderr, "") fmt.Fprintln(os.Stderr, "CUI: terminal interface using 'gocui'") fmt.Fprintln(os.Stderr, "GUI: linux and macos GUI using GTK") @@ -250,7 +262,7 @@ func (args) doBashAuto() { case "verify": fmt.Println("user devel master") default: - if argv.BashAuto[0] == ARGNAME { + if argv[0] == ARGNAME { // list the subcommands here fmt.Println("help list checkout clean commit dirty debug fetch gui normal merge patch pull") } diff --git a/main.go b/main.go index 2b33665..c1b8697 100644 --- a/main.go +++ b/main.go @@ -14,7 +14,7 @@ import ( "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" - "go.wit.com/lib/fhelp" + "go.wit.com/lib/gui/prep" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" @@ -47,17 +47,20 @@ func getVersion(repo *gitpb.Repo, name string) string { func main() { me = new(mainType) - gui.InitArg() + prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv) + me.myGui = prep.Gui() // prepares the GUI package for go-args me.pp = arg.MustParse(&argv) - if argv.Bash { - fhelp.DoBash(ARGNAME) - os.Exit(0) - } - if len(argv.BashAuto) != 0 { - argv.doBashAuto() - os.Exit(0) - } + /* + if argv.Bash { + fhelp.DoBash(ARGNAME) + os.Exit(0) + } + if len(argv.BashAuto) != 0 { + argv.doBashAuto() + os.Exit(0) + } + */ me.urlbase = argv.URL if me.urlbase == "" { me.urlbase = "https://go.wit.com/" @@ -185,7 +188,6 @@ func main() { okExit("") } - // if you are in "normal" mode, always run normal every time to catch accidental errors // for example, if you accidentally changed branches from your user branch if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL { @@ -194,7 +196,6 @@ func main() { } } - if argv.Merge != nil { if argv.Merge.Devel != nil { start := time.Now() @@ -243,7 +244,6 @@ func main() { okExit("") } - // if the user doesn't want to open the GUI and // nothing else was specified to be done, // then just list the table to stdout