diff options
Diffstat (limited to 'theMagicOfAutocomplete.go')
| -rw-r--r-- | theMagicOfAutocomplete.go | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go index fd75cf6..f67f9ff 100644 --- a/theMagicOfAutocomplete.go +++ b/theMagicOfAutocomplete.go @@ -10,36 +10,17 @@ import ( "strings" "time" - "github.com/google/uuid" "go.wit.com/lib/cobol" "go.wit.com/lib/config" "go.wit.com/lib/env" durationpb "google.golang.org/protobuf/types/known/durationpb" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" ) // This function behaves oddly. It works in several different ways. It can: // - Initialize a protobuf and returns it to the application // - Help a user generate shell completion support & os.Exit // - figures out what to print to Stdout & Stderr and then does os.Exit() -func Autocomplete(dest any) *Argv { - me = new(AutoArgs) // todo: redo this - me.pb = new(Argv) - PB = me.pb - fakeStdout() - me.pb.Uuid = uuid.New().String() - - // set the start time of the binary - now := time.Now() - me.pb.Ctime = timestamppb.New(now) - - // makes sure the application has the - // needed functions defined, otherwise dies - verifyApplication(dest) - - // gets APPNAME, BUILDTIME and VERSION from the application - initAppname() - +func Autocomplete() *Argv { // parses os.Args into the protobuf me.pb.parseOsArgs() @@ -238,10 +219,9 @@ func examineArgvHistory() { // only have nil values in the .pb file. just die for now if me.all.Len() == 0 { me.debug = true - me.pb.Stderr += fmt.Sprintf("examineArgvHistory() couldn't find a valid last entry") + fmt.Fprintf(Stderr, "examineArgvHistory() empty file %s\n", me.all.Filename) doStdoutStderr() - // todo: make a blank entry here - panic("examineArgvHistory() couldn't find a valid last entry") + saveAndExit() } // finally safe to get the last history entry |
