summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-27 01:36:26 -0500
committerJeff Carr <[email protected]>2025-10-27 01:36:26 -0500
commit8a0353dfd94e24d2b1a67a2b5c1cdac37c91ad35 (patch)
tree5919de8dca68c3b9d0b38f2bda9c2a52daaeeb2a
parent6eb6625374d6d0f0f81245f549ffac3542f29790 (diff)
minorv0.0.47
-rw-r--r--fakeStdout.go12
-rw-r--r--init.go7
2 files changed, 10 insertions, 9 deletions
diff --git a/fakeStdout.go b/fakeStdout.go
index b263f8a..0d349f0 100644
--- a/fakeStdout.go
+++ b/fakeStdout.go
@@ -1,5 +1,9 @@
package argvpb
+var Stdout *StringWriter // bash uses this to match strings
+var Stderr *StringWriter // bash dumps this as "help" about application options
+var Stddbg *StringWriter // argv writes it's internal debugging output here
+
// StringWriter is a custom type that implements the io.Writer interface
// for a string variable. It holds a pointer to the string it will write to.
type StringWriter struct {
@@ -19,14 +23,6 @@ func (sw *StringWriter) Write(p []byte) (n int, err error) {
return len(p), nil
}
-var Stdout *StringWriter
-var Stderr *StringWriter
-
-func fakeStdout() {
- Stdout = NewStringWriter(&PB.Stdout)
- Stderr = NewStringWriter(&PB.Stderr)
-}
-
/*
func main() {
// 1. Declare the string variable that will be our output destination.
diff --git a/init.go b/init.go
index a05acdf..68ee54f 100644
--- a/init.go
+++ b/init.go
@@ -14,6 +14,11 @@ func Init(dest any, APPNAME string, anyString string, VERSION string) {
me.pb = new(Argv)
PB = me.pb
+ // needed by bash for autocomplete, help & debugging
+ Stdout = NewStringWriter(&PB.Stdout) // bash uses this to match strings
+ Stderr = NewStringWriter(&PB.Stderr) // bash dumps this as "help" about application options
+ Stddbg = NewStringWriter(&PB.Stderr) // argv writes it's internal debugging output here
+
app := new(App)
app.APPNAME = APPNAME
app.VERSION = VERSION
@@ -37,7 +42,7 @@ func Init(dest any, APPNAME string, anyString string, VERSION string) {
}
me.pb.AppInfo = app
- fakeStdout()
+ // shouldn't be needed but is because this code doesn't work right yet
me.pb.Uuid = uuid.New().String()
// set the start time of the binary