summaryrefslogtreecommitdiff
path: root/interface.go
diff options
context:
space:
mode:
Diffstat (limited to 'interface.go')
-rw-r--r--interface.go246
1 files changed, 0 insertions, 246 deletions
diff --git a/interface.go b/interface.go
deleted file mode 100644
index ad343d3..0000000
--- a/interface.go
+++ /dev/null
@@ -1,246 +0,0 @@
-package argvpb
-
-import (
- "go.wit.com/lib/cobol"
- "go.wit.com/log"
-)
-
-// this is a work in progress
-
-// WORKING ON START
-
-type initArgvI interface {
- InitArgv() (string, string, string)
-}
-
-type mustParseI interface {
- MustParse() error
-}
-
-type parseFlagsI interface {
- ParseFlags([]string) error
-}
-
-type writeHelpForAutocompleteI interface {
- WriteHelpForAutocomplete(string, ...string) error
-}
-
-type writeHelpForAutocompleteDebugI interface {
- WriteHelpForAutocompleteDebug(string, ...string) error
-}
-
-type writeHelpForSubcommandI interface {
- WriteHelpForSubcommand(cmd string) 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.
- InitGui() error
-}
-
-// WORKING ON END
-
-// NOTSURE ABOUT START
-type appnameI interface {
- // Version returns the version string that will be printed on a line by itself
- // at the top of the help message.
- Appname() string
-}
-
-// deprecate
-type autoFuncI interface {
- // Version returns the version string that will be printed on a line by itself
- // at the top of the help message.
- DoAutoComplete(*Argv)
-}
-
-type sendCompletionStringsI interface {
- // Version returns the version string that will be printed on a line by itself
- // at the top of the help message.
- SendCompletionStrings(*Argv)
-}
-
-type buildtimeI interface {
- Buildtime() (string, string)
-}
-
-type examplesI interface {
- // Version returns the version string that will be printed on a line by itself
- // at the top of the help message.
- Examples() string
-}
-
-type guiI interface {
- // Version returns the version string that will be printed on a line by itself
- // at the top of the help message.
- ArgvGui() error
-}
-
-type exitI interface {
- // allows a custom app Exit()
- Exit()
-}
-
-// Described is the interface that the destination struct should implement to
-func findAppInfo(tmp interface{}) {
- // THIS STUFF IS FINALIZED FOR NOW 2025/10/18 (review in a few months)
- if tmp, ok := tmp.(initArgvI); ok {
- var anyTime string
- var err error
- me.ARGNAME, anyTime, me.VERSION = tmp.InitArgv()
- me.BUILDTIME, err = cobol.GetTime(anyTime)
- _ = err
- } else {
- panic("you must define in your app the function: (args) func InitArgv() (string, string, string)")
- }
-
- if tmp, ok := tmp.(mustParseI); ok {
- me.mustParseFunc = tmp.MustParse
- } else {
- 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 {
- log.Info("go.wit.com/gui failed to initialize", err)
- panic("gui failed to init")
- }
- } else {
- // panic("you must add this function to argv.go: (argv) func InitGui() error")
- }
-
- // TODO: SORT OUT STUFF BELOW HERE
- if tmp, ok := tmp.(appnameI); ok {
- me.ARGNAME = tmp.Appname()
- } else {
- // panic("you must define in your app the function: (argv) func Appname() string")
- }
-
- /*
- if tmp, ok := tmp.(buildtimeI); ok {
- me.buildtime = tmp.Buildtime
- me.BUILDTIME, me.VERSION = me.buildtime()
- } else {
- // panic("your app is missing (argv) func Buildtime() (string, string)")
- }
- */
-
- if tmp, ok := tmp.(examplesI); ok {
- me.examples = tmp.Examples
- }
- if tmp, ok := tmp.(autoFuncI); ok {
- me.autoFunc = tmp.DoAutoComplete
- } else {
- // panic("you need to make the function argv.DoAutoComplete()")
- }
-
- if tmp, ok := tmp.(sendCompletionStringsI); ok {
- me.autoFunc = tmp.SendCompletionStrings
- } else {
- // panic("you need to make the function argv.DoAutoComplete()")
- }
-
- if tmp, ok := tmp.(exitI); ok {
- me.appExit = tmp.Exit
- } else {
- // panic("you need to make the function argv.Exit()")
- }
-}
-
-func helpWriteHelpForSubcommand() {
- log.Info("")
- log.Info("// add this funcgion: this will print the help")
- log.Info("func (args) WriteHelpForSubcommand() error {")
- log.Info(" me.pp.WriteHelpForSubcommand(os.Stderr, me.argv.Cmd)")
- log.Info(" return nil")
- log.Info("}")
- log.Info("")
- log.Info("cp ~/go/src/go.wit.com/apps/forge/argv.template.go .")
- panic("copy the argv.template.go file from forge")
-}
-
-func helpWriteHelp() {
- log.Info("")
- log.Info("// add this funcgion: this will print the help")
- log.Info("func (args) WriteHelp() error {")
- log.Info(" me.pp.WriteHelp(os.Stderr)")
- log.Info(" return nil")
- log.Info("}")
- log.Info("")
-
- panic("best to just copy the argv.template.go file from forge")
-}
-
-func helpWriteHelpForAutocompleteDebug() {
- log.Info("")
- log.Info("// this will print the help for the subcmd")
- log.Info("func (args) WriteHelpForAutocompleteDebug(part string, subcmd ...string) error {")
- log.Info(" return argvpp.WriteHelpForAutocomplete(f, os.Stdout, part, subcmd...)")
- log.Info("}")
- log.Info("")
- log.Info("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(os.Stderr, os.Stdout, partial, cmd...)
-func helpWriteHelpForAutocomplete() {
- log.Info("")
- log.Info("// this will print the help for the subcmd")
- log.Info("func (args) WriteHelpForAutocomplete(part string, subcmd ...string) error {")
- log.Info(" return argvpp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, part, subcmd...)")
- log.Info("}")
- log.Info("")
- log.Info("Just copy the argv.template.go file from forge")
- log.Info("")
-
- panic("you must define this function in your application code")
-}
-
-func parseFlagsHelp() {
- log.Info("")
- log.Info("// this function will send the current argv PB to go-args for parsing")
- log.Info("func (args) ParseFlags(flags []string) error {")
- log.Info(" arg.ParseFlags(flags)")
- log.Info("}")
- log.Info("")
-
- panic("you must define in your app the function: func (args) ParseFlags([]string) error")
-}