diff options
Diffstat (limited to 'theMagicOfAutocomplete.go')
| -rw-r--r-- | theMagicOfAutocomplete.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go index 89560c5..eadffb6 100644 --- a/theMagicOfAutocomplete.go +++ b/theMagicOfAutocomplete.go @@ -14,6 +14,7 @@ import ( timestamppb "google.golang.org/protobuf/types/known/timestamppb" ) +// 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 @@ -26,13 +27,21 @@ func Autocomplete(dest any) *Auto { // log.Info("no gui init") } - // load the argv history from the protobuf file + // parses os.Args into a protobuf + pb := parseArgv(myAuto.ARGNAME) + + // the argv history all := NewAutos() - err := config.LoadCache(all, "argv", myAuto.appName) // loads ~/.cache/argv/forge.pb + + // initializes the application config file + config.Init(myAuto.ARGNAME, myAuto.VERSION, myAuto.BUILDTIME, pb.Argv) + + // loads the autocomplete history file + err := config.LoadCache(all, "argv", myAuto.ARGNAME) // if err != nil { - // there is no history. do something here(?) + // there is no history. + // todo: initialize the history file } - pb := parseArgv(myAuto.appName) // parses os.Args into a protobuf // set the start time of the binary now := time.Now() @@ -46,7 +55,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.appName) + MakeAutocompleteFiles(myAuto.ARGNAME) // never forget to run this our you will hate yourself and the choices you have made os.Exit(0) } |
