summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-25 21:37:10 -0500
committerJeff Carr <[email protected]>2025-10-25 21:37:10 -0500
commitcfee0dad2418f8e800d15edd3e6b32cebd1119dc (patch)
tree1a04efc1fb679c18a2694f20880bf5d5989bf678
parentc4808b62d90562eb901e37f242ee866dc07d07c6 (diff)
dump lots more stuff
-rw-r--r--structs.go40
-rw-r--r--theMagicOfAutocomplete.go48
-rw-r--r--verifyApplication.go114
3 files changed, 18 insertions, 184 deletions
diff --git a/structs.go b/structs.go
index 57635de..40912f4 100644
--- a/structs.go
+++ b/structs.go
@@ -7,27 +7,21 @@ var PB *Argv
// this is a work in progress
type AutoArgs struct {
- pb *Argv // the protobuf for the current process
- all *Argvs // the history of argv
- last *Argv // the pb from the last time the user tried autocomplete
- Err error // store any errors from argv
- debug bool // is dubugging on?
- setupAuto bool // do shell autocomplete setup
- isAuto bool // try to do autocomplete
- id int // should be unique
- Argv func([]string) // the function for shell autocomplete
- initArgvFunc func() (string, string, string) // this is required. gets APPNAME, BUILDTIME & VERSION
- initGuiFunc func() error // this is required for 'gui' args to work
- mustParseFunc func() error // calls go-arg.MustParse()
- parseFlagsFunc func() error // calls go-arg.ParseFlags(flags)
- writeHelpForAutocompleteFunc func() error // notsure yet
- writeHelpForAutocompleteDebugFunc func() error // notsure yet
- writeHelpFunc func() error // notsure yet
- writeHelpForSubcommandFunc func() error // notsure yet
- examples func() string // some examples
- appExit func() // app Exit()
- buildtime func() (string, string) // some examples
- autoFunc func(*Argv) // also a function for autocomplete
- guiFunc func() error // enables Gui functions
- // flags []string // notsure
+ pb *Argv // the protobuf for the current process
+ all *Argvs // the history of argv
+ last *Argv // the pb from the last time the user tried autocomplete
+ Err error // store any errors from argv
+ debug bool // is dubugging on?
+ setupAuto bool // do shell autocomplete setup
+ isAuto bool // try to do autocomplete
+ id int // should be unique
+ Argv func([]string) // the function for shell autocomplete
+ initArgvFunc func() (string, string, string) // this is required. gets APPNAME, BUILDTIME & VERSION
+ initGuiFunc func() error // this is required for 'gui' args to work
+ mustParseFunc func() error // calls go-arg.MustParse()
+ examples func() string // some examples
+ appExit func() // app Exit()
+ buildtime func() (string, string) // some examples
+ autoFunc func(*Argv) // also a function for autocomplete
+ guiFunc func() error // enables Gui functions
}
diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go
index f1d427d..fd75cf6 100644
--- a/theMagicOfAutocomplete.go
+++ b/theMagicOfAutocomplete.go
@@ -125,37 +125,6 @@ func prepareStdout() {
}
}
- // use go-args to parse the structs so we can use them here
- // me.pp, err = arg.ParseFlags(pb.Real, dest)
- if me.parseFlagsFunc == nil {
- me.pb.Stderr += fmt.Sprintln("argv.parseFlags() is nil")
- me.debug = true
- return
- }
-
- if len(PB.Real) > 1 {
- fmt.Fprintf(Stderr, "going to parseFlagsFunc() err(%v)\n", me.Err)
- fmt.Fprintf(Stderr, "going to parseFlagsFunc() PB.Real(%v) len(PB.Real)=%d\n", PB.Real, len(PB.Real))
- if err := me.parseFlagsFunc(); err != nil {
- me.pb.Stderr += fmt.Sprintf("application parseFlags() err(%v)\n", err)
- me.pb.Stderr += fmt.Sprintln("argv.parseFlags() err. probably cmd doesn't really exist in struct")
- me.debug = true
- return
- }
- fmt.Fprintf(Stderr, "did parseFlagsFunc() err(%v)\n", me.Err)
- } else {
- fmt.Fprintf(Stderr, "DID NOT RUN parseFlagsFunc() err(%v)\n", me.Err)
- }
-
- if len(me.pb.Real) == 0 {
- // error is normal if there are no command line args
- } else {
- if me.Err != nil {
- // users has command line arguments that won't parse with go-args
- me.pb.Debugf("DEBUG: Parse error: %v real(%v)", me.Err, me.pb.Real)
- }
- }
-
me.pb.HelpCounter = me.last.HelpCounter
fmt.Fprintf(Stderr, "got to HelpCounter check err(%v)\n", me.Err)
@@ -163,27 +132,10 @@ func prepareStdout() {
if me.last.Fast {
me.pb.HelpCounter = me.last.HelpCounter + 1
} else {
- // this means the user is pressing tab. no longer doing stderr
- if me.pb.GetCmd() == "" {
- // me.pp.WriteHelp(Stderr)
- me.writeHelpFunc()
- } else {
- // me.pp.WriteHelpForSubcommand(Stderr, me.pb.Cmd)
- me.writeHelpForSubcommandFunc()
- }
me.pb.HelpCounter = 0
}
} else {
- // if me.autoFunc == nil {
- // me.pb.SubCommand(me.pb.Real...)
- // } else {
me.autoFunc(me.pb) // run the autocomplete function the user made for their application
- // }
- // if me.debug {
- // TODO:
- // check here to see if there was any completion text sent
- // if not, send "reset bash newline\n" to cause bash to redraw PS1 for the user
- // }
}
fmt.Fprintf(Stderr, "got to the end err(%v)\n", me.Err)
return
diff --git a/verifyApplication.go b/verifyApplication.go
index 6b0291a..f38bec7 100644
--- a/verifyApplication.go
+++ b/verifyApplication.go
@@ -17,36 +17,6 @@ func verifyApplication(tmp interface{}) {
panic("you must define in your app the function: func (args) MustParse() error")
}
- if tmp, ok := tmp.(writeHelpForAutocompleteI); ok {
- me.writeHelpForAutocompleteFunc = tmp.WriteHelpForAutocomplete
- } else {
- helpWriteHelpForAutocomplete()
- }
-
- if tmp, ok := tmp.(writeHelpForAutocompleteDebugI); ok {
- me.writeHelpForAutocompleteDebugFunc = tmp.WriteHelpForAutocompleteDebug
- } else {
- helpWriteHelpForAutocompleteDebug()
- }
-
- if tmp, ok := tmp.(writeHelpForSubcommandI); ok {
- me.writeHelpForSubcommandFunc = tmp.WriteHelpForSubcommand
- } else {
- helpWriteHelpForSubcommand()
- }
-
- if tmp, ok := tmp.(writeHelpI); ok {
- me.writeHelpFunc = tmp.WriteHelp
- } else {
- helpWriteHelp()
- }
-
- if tmp, ok := tmp.(parseFlagsI); ok {
- me.parseFlagsFunc = tmp.ParseFlags
- } else {
- parseFlagsHelp()
- }
-
if tmp, ok := tmp.(initGuiI); ok {
me.initGuiFunc = tmp.InitGui
if err := tmp.InitGui(); err != nil {
@@ -71,7 +41,7 @@ func verifyApplication(tmp interface{}) {
if tmp, ok := tmp.(sendCompletionStringsI); ok {
me.autoFunc = tmp.SendCompletionStrings
} else {
- // panic("you need to make the function argv.DoAutoComplete()")
+ // panic("you need to make the function argv.SendCompletionStrings()")
}
if tmp, ok := tmp.(exitI); ok {
@@ -91,26 +61,6 @@ type mustParseI interface {
MustParse() error
}
-type parseFlagsI interface {
- ParseFlags() error
-}
-
-type writeHelpForAutocompleteI interface {
- WriteHelpForAutocomplete() error
-}
-
-type writeHelpForAutocompleteDebugI interface {
- WriteHelpForAutocompleteDebug() error
-}
-
-type writeHelpForSubcommandI interface {
- WriteHelpForSubcommand() error
-}
-
-type writeHelpI interface {
- WriteHelp() error
-}
-
type initGuiI interface {
// Version returns the version string that will be printed on a line by itself
// at the top of the help message.
@@ -159,65 +109,3 @@ type exitI interface {
// allows a custom app Exit()
Exit()
}
-
-func helpWriteHelpForSubcommand() {
- fmt.Println("")
- fmt.Println("// add this funcgion: this will print the help")
- fmt.Println("func (args) WriteHelpForSubcommandArgv() error {")
- fmt.Println(" me.pp.WriteHelpForSubcommandArgv(me.argv)")
- fmt.Println(" return nil")
- fmt.Println("}")
- fmt.Println("")
- fmt.Println("cp ~/go/src/go.wit.com/apps/forge/argv.template.go .")
- panic("copy the argv.template.go file from forge")
-}
-
-func helpWriteHelp() {
- fmt.Println("")
- fmt.Println("// add this funcgion: this will print the help")
- fmt.Println("func (args) WriteHelp() error {")
- fmt.Println(" me.pp.WriteHelpArgv(me.argv)")
- fmt.Println(" return nil")
- fmt.Println("}")
- fmt.Println("")
-
- panic("best to just copy the argv.template.go file from forge")
-}
-
-func helpWriteHelpForAutocompleteDebug() {
- fmt.Println("")
- fmt.Println("// this will print the help for the subcmd")
- fmt.Println("func (args) WriteHelpForAutocompleteDebugArgv() error {")
- fmt.Println(" return argvpp.WriteHelpForAutocompleteArgv(me.argv)")
- fmt.Println("}")
- fmt.Println("")
- fmt.Println("cp ~/go/src/go.wit.com/apps/forge/argv.template.go .")
-
- panic("best to just copy the argv.template.go file from forge")
-}
-
-// func (p *Parser) WriteHelpForAutocomplete(stderr io.Writer, stdout io.Writer, partial string, subcommand ...string) error {
-// me.pp.WriteHelpForAutocomplete(Stderr, Stdout, partial, cmd...)
-func helpWriteHelpForAutocomplete() {
- fmt.Println("")
- fmt.Println("// this will print the help for the subcmd")
- fmt.Println("func (args) WriteHelpForAutocompleteArgv() error {")
- fmt.Println(" return argvpp.WriteHelpForAutocompleteArgv(me.argv)")
- fmt.Println("}")
- fmt.Println("")
- fmt.Println("Just copy the argv.template.go file from forge")
- fmt.Println("")
-
- panic("you must define this function in your application code")
-}
-
-func parseFlagsHelp() {
- fmt.Println("")
- fmt.Println("// this function will send the current argv PB to go-args for parsing")
- fmt.Println("func (args) ParseFlags() error {")
- fmt.Println(" arg.ParseFlags(me.argv, &argv)")
- fmt.Println("}")
- fmt.Println("")
-
- panic("you must define in your app the function: func (args) ParseFlags([]string) error")
-}