summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-27 18:39:18 -0500
committerJeff Carr <[email protected]>2025-10-27 18:39:18 -0500
commit4b096312a8ad49d0079242dc274c7c4a8a2cb31a (patch)
tree3621600ec15dc43ae552dbd45fe5d926c7cf2722
parent8a0353dfd94e24d2b1a67a2b5c1cdac37c91ad35 (diff)
trying to fix helpv0.0.48
-rw-r--r--argv.Match.go15
-rw-r--r--argv.Print.go10
-rw-r--r--argv.parseOsArgs.go4
-rw-r--r--argv.proto1
-rw-r--r--init.go2
-rw-r--r--theMagicOfAutocomplete.go18
6 files changed, 35 insertions, 15 deletions
diff --git a/argv.Match.go b/argv.Match.go
index e9670a7..f06f0f7 100644
--- a/argv.Match.go
+++ b/argv.Match.go
@@ -19,3 +19,18 @@ func (pb *Argv) IsMatch(match string) bool {
}
return true
}
+
+func Len() int {
+ counter := 0
+ for _, s := range PB.Real {
+ s = strings.TrimSpace(s)
+ if s == "" {
+ continue
+ }
+ if strings.HasPrefix(s, "--") {
+ continue
+ }
+ counter += 1
+ }
+ return counter
+}
diff --git a/argv.Print.go b/argv.Print.go
index 2d7ea80..7c89404 100644
--- a/argv.Print.go
+++ b/argv.Print.go
@@ -20,7 +20,7 @@ func Debugf(fmts string, parts ...any) {
fmts = strings.TrimSpace(fmts)
fmts += "\n"
// me.pb.Stderr += fmt.Sprintf(fmts, parts...)
- fmt.Fprintf(Stderr, fmts, parts...)
+ fmt.Fprintf(Stddbg, fmts, parts...)
}
// print out auto complete debugging info
@@ -77,10 +77,10 @@ func PrintStderr() {
}
fmt.Fprintf(os.Stderr, "\n")
for _, line := range lines {
- line = strings.TrimSpace(line)
- if line == "" {
- continue
- }
+ // line = strings.TrimSpace(line)
+ // if line == "" {
+ // continue
+ // }
fmt.Fprintf(os.Stderr, "%s\n", line)
}
fmt.Fprintf(os.Stderr, "\n")
diff --git a/argv.parseOsArgs.go b/argv.parseOsArgs.go
index 5df4a8d..b82a92a 100644
--- a/argv.parseOsArgs.go
+++ b/argv.parseOsArgs.go
@@ -12,6 +12,10 @@ func GetCmd() string {
return PB.GetCmd()
}
+func SetDebug(b bool) {
+ me.debug = b
+}
+
func mypanic(blah string) {
me.debug = true
doStdoutStderr()
diff --git a/argv.proto b/argv.proto
index 4a37932..0d5763b 100644
--- a/argv.proto
+++ b/argv.proto
@@ -39,6 +39,7 @@ message Argv { // `autogenpb:marshal
string stderr = 10; // all output is loaded here before being sent to the shell
int32 helpCounter = 11; // counter to track if the help text has been sent to Stderr
string uuid = 12; // all output is loaded here before being sent to the shell
+ string stddbg = 13; // all output is loaded here before being sent to the shell
}
message Argvs { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:nomutex`
diff --git a/init.go b/init.go
index 68ee54f..a5b6c35 100644
--- a/init.go
+++ b/init.go
@@ -17,7 +17,7 @@ func Init(dest any, APPNAME string, anyString string, VERSION string) {
// 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
+ Stddbg = NewStringWriter(&PB.Stddbg) // argv writes it's internal debugging output here
app := new(App)
app.APPNAME = APPNAME
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index db1a95b..92163cb 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -63,11 +63,11 @@ func Autocomplete() *Argv {
// savePB()
// me.pp = arg.MustParse(dest)
me.Err = errors.Join(me.Err, me.mustParseFunc())
- fmt.Fprintf(Stderr, "did mustParseFunc(). heading to forge. err(%v)\n", me.Err)
+ fmt.Fprintf(Stddbg, "did mustParseFunc(). heading to forge. err(%v)\n", me.Err)
doStdoutStderr()
return me.pb
}
- fmt.Fprintf(Stderr, "heading to autocomplete. err(%v)\n", me.Err)
+ fmt.Fprintf(Stddbg, "heading to autocomplete. err(%v)\n", me.Err)
prepareStdout()
// print to Stdout & Stderr
@@ -88,7 +88,7 @@ func prepareStdout() {
if strings.HasPrefix(me.pb.Partial, "'--argv") {
fmt.Fprintf(Stdout, " --argvdebug --argvhelp")
- me.pb.Stderr += fmt.Sprintln("argv override")
+ me.pb.Stddbg += fmt.Sprintln("argv override")
me.debug = true
return
}
@@ -107,7 +107,7 @@ func prepareStdout() {
}
me.pb.HelpCounter = me.last.HelpCounter
- fmt.Fprintf(Stderr, "got to HelpCounter check err(%v)\n", me.Err)
+ fmt.Fprintf(Stddbg, "got to HelpCounter check err(%v)\n", me.Err)
if me.pb.Fast {
if me.last.Fast {
@@ -118,7 +118,7 @@ func prepareStdout() {
} else {
errors.Join(me.Err, me.autoFunc()) // run the autocomplete function the user made for their application
}
- fmt.Fprintf(Stderr, "got to the end err(%v)\n", me.Err)
+ fmt.Fprintf(Stddbg, "got to the end err(%v)\n", me.Err)
return
}
@@ -134,11 +134,11 @@ func savePB() {
func doStdoutStderr() {
if me.debug {
me.all.PrintHistory(me.last.GetCmd())
- fmt.Fprintf(Stderr, "debug=true pb.Stdout (%v)\n", PB.Stdout)
+ fmt.Fprintf(Stddbg, "debug=true pb.Stdout (%v)\n", PB.Stdout)
} else {
if me.pb.Fast {
if me.pb.HelpCounter < 3 {
- fmt.Fprintf(Stderr, "help counter < 3\n")
+ fmt.Fprintf(Stddbg, "help counter < 3\n")
}
}
}
@@ -167,7 +167,7 @@ func examineArgvHistory() {
// so this panic() is safe and can never be triggered by normal program execution.
//
me.debug = true
- me.pb.Stderr += fmt.Sprintf("config.CreateCacheDirPB() err(%v)\n", me.Err)
+ me.pb.Stddbg += fmt.Sprintf("config.CreateCacheDirPB() err(%v)\n", me.Err)
doStdoutStderr()
panic("argvpb.Load() history file failed")
}
@@ -219,7 +219,7 @@ func examineArgvHistory() {
// only have nil values in the .pb file. just die for now
if me.all.Len() == 0 {
me.debug = true
- fmt.Fprintf(Stderr, "examineArgvHistory() empty file %s\n", me.all.Filename)
+ fmt.Fprintf(Stddbg, "examineArgvHistory() empty file %s\n", me.all.Filename)
doStdoutStderr()
saveAndExit()
}