summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go35
1 files changed, 25 insertions, 10 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index ee20b24..bcae20d 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -18,14 +18,29 @@ import (
// gets APPNAME, BUILDTIME and VERSION from the application
func initAppname() {
- ARGNAME, anyString, VERSION := me.initArgvFunc()
- me.ARGNAME = ARGNAME
- me.VERSION = VERSION
- var err error
- me.BUILDTIME, err = cobol.GetTime(anyString)
- if err != nil {
- log.Printf("TIME ERR=(%v) time=(%v) BUILTIME=(%v)\n", err, anyString, me.BUILDTIME)
+ app := new(App)
+ APPNAME, anyString, VERSION := me.initArgvFunc()
+ app.APPNAME = APPNAME
+ app.VERSION = VERSION
+ //
+ // this logic isn't great, but it's what it is right now
+ //
+ // the reason this logic is messy is because cobol is supposed to "guess"
+ // that is the point of the cobol package and I've been using this code here
+ // to test the guesses because it's an easy place to test that code
+ //
+ if BUILDTIME, err := cobol.GetTime(anyString); BUILDTIME != nil {
+ // everyhting is working. BUILDTIME is *time.Time
+ app.BUILDTIME = cobol.Time(BUILDTIME)
+ } else if err == nil {
+ newtime := BUILDTIME.Add(-36 * time.Hour)
+ app.BUILDTIME = cobol.Time(BUILDTIME)
+ log.Printf("TIME initAppname() ERR=(%v) anyString=(%v) GetTime.BUILTIME=(%v) app.BUILDTIME=(%v)\n", err, anyString, newtime, app.BUILDTIME)
+ } else {
+ app.BUILDTIME = anyString
+ log.Printf("TIME initAppname() ERR=(%v) anyString=(%v) GetTime.BUILTIME=(%v) app.BUILDTIME=(%v)\n", err, anyString, BUILDTIME, app.BUILDTIME)
}
+ me.pb.AppInfo = app
}
func Autocomplete(dest any) *Argv {
@@ -55,10 +70,10 @@ func Autocomplete(dest any) *Argv {
all := NewArgvs()
// initializes the application config file
- config.Init(me.ARGNAME, me.VERSION, cobol.Time(me.BUILDTIME), me.pb.Real)
+ config.Init(me.pb.AppInfo.APPNAME, me.pb.AppInfo.VERSION, cobol.Time(me.pb.AppInfo.BUILDTIME), me.pb.Real)
// loads the autocomplete history file
- err := config.LoadCache(all, "argv", me.ARGNAME) //
+ err := config.LoadCache(all, "argv", me.pb.AppInfo.APPNAME) //
if err != nil {
// there is no history.
// todo: initialize the history file
@@ -76,7 +91,7 @@ func Autocomplete(dest any) *Argv {
// --bash or --zsh is the first os.Args
if me.pb.SetupAuto {
// --bash or --zsh was passed. try to configure bash-completion
- MakeAutocompleteFiles(me.ARGNAME)
+ MakeAutocompleteFiles(me.pb.AppInfo.APPNAME)
// never forget to run this our you will hate yourself and the choices you have made
os.Exit(0)
}