summaryrefslogtreecommitdiff
path: root/bash.orig.go
diff options
context:
space:
mode:
Diffstat (limited to 'bash.orig.go')
-rw-r--r--bash.orig.go64
1 files changed, 41 insertions, 23 deletions
diff --git a/bash.orig.go b/bash.orig.go
index 77b7e56..d095db5 100644
--- a/bash.orig.go
+++ b/bash.orig.go
@@ -5,12 +5,10 @@ package prep
import (
"fmt"
"os"
- "path/filepath"
"strings"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/gui/shell"
- "go.wit.com/log"
)
/*
@@ -37,33 +35,28 @@ type AutoArgs struct {
match map[string]string // maps for strings
}
-// argname is the name of the executable
-func Bash(argname string, autocomplete func([]string)) *AutoArgs {
- myAuto = new(AutoArgs)
- myAuto.appName = argname
-
- if len(os.Args) > 1 && os.Args[1] == "--bash" {
- doBash(argname)
- os.Exit(0)
- }
-
- if len(os.Args) > 1 && os.Args[1] == "--auto-complete" {
- autocomplete(os.Args[2:])
- os.Exit(0)
- }
-
- arg.Register(&argBash)
-
- // parse go.Arg here?
- return myAuto
-}
-
// print out auto complete debugging info
func (pb *Auto) PrintDebug() {
dur := pb.Duration.AsDuration()
pb.Debugf("AUTOCOMPLETE: arg0='%s' arg1='%s' partial='%s' cmd='%s' age=%s argv=%v\n", pb.Arg0, pb.Arg1, pb.Partial, pb.Cmd, shell.FormatDuration(dur), pb.Argv)
}
+func (pb *Auto) Debugf(fmts string, parts ...any) {
+ fmts = strings.TrimSpace(fmts)
+ fmts += "\n"
+ // NOTE: env doesn't work probably most (all?) the time because bash
+ // doesn't send all the ENV to autocomplete. so, trap on a "--autodebug" command line arg
+ if os.Getenv("AUTOCOMPLETE_VERBOSE") == "true" || pb.Debug {
+ if !pb.Newline {
+ fmt.Fprintf(os.Stderr, "\n")
+ pb.Newline = true
+ }
+ fmt.Fprintf(os.Stderr, fmts, parts...)
+ } else {
+ // fmt.Fprintf(os.Stderr, "NOT DOING ANYTHING\n")
+ }
+}
+
// returns the last command (is blank if the current arg is not blank)
func GetLast(cur string, argv []string) string {
if cur != "''" {
@@ -83,6 +76,7 @@ func AppName() string {
return myAuto.appName
}
+/*
// makes a bash autocomplete file for your command
func doBash(argname string) {
fmt.Println(makeBashCompletionText(argname))
@@ -112,3 +106,27 @@ func doBash(argname string) {
}
os.Exit(0)
}
+*/
+
+/*
+// argname is the name of the executable
+func Bash(argname string, autocomplete func([]string)) *AutoArgs {
+ myAuto = new(AutoArgs)
+ myAuto.appName = argname
+
+ if len(os.Args) > 1 && os.Args[1] == "--bash" {
+ doBash(argname)
+ os.Exit(0)
+ }
+
+ if len(os.Args) > 1 && os.Args[1] == "--auto-complete" {
+ autocomplete(os.Args[2:])
+ os.Exit(0)
+ }
+
+ arg.Register(&argBash)
+
+ // parse go.Arg here?
+ return myAuto
+}
+*/