summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index 1eeedd1..648e28f 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -17,28 +17,28 @@ import (
// TODO: rename 'all' to 'pb' and 'pb' to 'pbnew' or 'pbcur'
func Autocomplete(dest any) *Auto {
- myAuto = new(AutoArgs) // todo: redo this
- findAppInfo(dest) // parses back to main() for argv info
+ me = new(AutoArgs) // todo: redo this
+ findAppInfo(dest) // parses back to main() for argv info
- if myAuto.guiFunc != nil {
+ if me.guiFunc != nil {
// register gui args
- myAuto.guiFunc()
+ me.guiFunc()
// log.Info("gui init")
} else {
// log.Info("no gui init")
}
// parses os.Args into a protobuf
- pb := parseArgv(myAuto.ARGNAME)
+ pb := parseArgv(me.ARGNAME)
// the argv history
all := NewAutos()
// initializes the application config file
- config.Init(myAuto.ARGNAME, myAuto.VERSION, myAuto.BUILDTIME, pb.Argv)
+ config.Init(me.ARGNAME, me.VERSION, me.BUILDTIME, pb.Argv)
// loads the autocomplete history file
- err := config.LoadCache(all, "argv", myAuto.ARGNAME) //
+ err := config.LoadCache(all, "argv", me.ARGNAME) //
if err != nil {
// there is no history.
// todo: initialize the history file
@@ -56,7 +56,7 @@ func Autocomplete(dest any) *Auto {
// --bash or --zsh is the first os.Args
if pb.SetupAuto {
// --bash was passed. try to configure bash-completion
- MakeAutocompleteFiles(myAuto.ARGNAME)
+ MakeAutocompleteFiles(me.ARGNAME)
// never forget to run this our you will hate yourself and the choices you have made
os.Exit(0)
}
@@ -67,8 +67,8 @@ func Autocomplete(dest any) *Auto {
all.Clone(pb)
errors.Join(err, all.Save())
- myAuto.pp = arg.MustParse(dest)
- myAuto.err = err
+ me.pp = arg.MustParse(dest)
+ me.err = err
return pb
}
@@ -129,7 +129,7 @@ func Autocomplete(dest any) *Auto {
}
// use go-args to parse the structs so we can use them here
- myAuto.pp, err = arg.ParseFlags(flags, dest)
+ me.pp, err = arg.ParseFlags(flags, dest)
if len(flags) == 0 {
// error is normal if there are no command line args
} else {
@@ -139,10 +139,10 @@ func Autocomplete(dest any) *Auto {
}
}
- if myAuto.pp == nil {
- pb.Debugf("DEBUG: myAuto.pp == nil after ParseFlags()")
+ if me.pp == nil {
+ pb.Debugf("DEBUG: me.pp == nil after ParseFlags()")
} else {
- // pb.Debugf("DEBUG: myAuto.pp is ok after ParseFlags()")
+ // pb.Debugf("DEBUG: me.pp is ok after ParseFlags()")
}
// save now. this is near the end probably
@@ -164,18 +164,18 @@ func Autocomplete(dest any) *Auto {
} else {
// this means the user is pressing tab. no longer doing stderr
if pb.Cmd == "" {
- myAuto.pp.WriteHelp(os.Stderr)
+ me.pp.WriteHelp(os.Stderr)
} else {
- myAuto.pp.WriteHelpForSubcommand(os.Stderr, pb.Cmd)
+ me.pp.WriteHelpForSubcommand(os.Stderr, pb.Cmd)
}
}
} else {
}
- if myAuto.autoFunc == nil {
+ if me.autoFunc == nil {
pb.SubCommand(pb.Argv...)
} else {
- myAuto.autoFunc(pb) // run the autocomplete function the user made for their application
+ me.autoFunc(pb) // run the autocomplete function the user made for their application
}
if pb.Debug {
// TODO: