summaryrefslogtreecommitdiff
path: root/theMagicOfAutocomplete.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-26 08:31:13 -0500
committerJeff Carr <[email protected]>2025-10-26 08:31:13 -0500
commit042fac23113c134b3615939b0836263fd12b3bd1 (patch)
treeb46492b135af76e0e045e887c6a5ea941516c490 /theMagicOfAutocomplete.go
parentcfee0dad2418f8e800d15edd3e6b32cebd1119dc (diff)
new argv Init()
Diffstat (limited to 'theMagicOfAutocomplete.go')
-rw-r--r--theMagicOfAutocomplete.go26
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