From 8c44dd2eb48319b3511982e78dc6ef06b43ea3ac Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 19 Oct 2025 11:41:24 -0500 Subject: further cleanup order of theMagic() --- argv.parseOsArgs.go | 150 ++++++++++++++++++++++++++++ interface.go | 246 ---------------------------------------------- parseOsArgs.go | 153 ---------------------------- structs.go | 2 +- theMagicOfAutocomplete.go | 27 ++++- verifyApplication.go | 231 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 405 insertions(+), 404 deletions(-) create mode 100644 argv.parseOsArgs.go delete mode 100644 interface.go delete mode 100644 parseOsArgs.go create mode 100644 verifyApplication.go diff --git a/argv.parseOsArgs.go b/argv.parseOsArgs.go new file mode 100644 index 0000000..eb6f7d6 --- /dev/null +++ b/argv.parseOsArgs.go @@ -0,0 +1,150 @@ +package argvpb + +// initializes logging and command line options + +import ( + "fmt" + "os" + "strings" + + "go.wit.com/log" +) + +func (pb *Argv) parseArgv() { + // this shouldn't really happen. OS/POSIX error? + if len(os.Args) == 0 { + // fmt.Fprintf(os.Stderr, "what OS is this?\n") + return + } + + // there is nothing on the command line. user just ran "forge" and hit enter + if len(os.Args) == 1 { + pb.Arg0 = os.Args[0] + return + } + + // try to setup bash autocomplete and exit + if len(os.Args) > 1 && os.Args[1] == "--bash" { + pb.SetupAuto = true + return + } + + // try to setup zsh autocomplete and exit + if len(os.Args) > 1 && os.Args[1] == "--zsh" { + pb.SetupAuto = true + return + } + + // set debug flag if --argvdebug is passed + for _, s := range os.Args { + if s == "--argvdebug" { + pb.Debug = true + } + // deprecate + if s == "--autodebug" { + pb.Debug = true + } + } + + // wtf is this. I've forgotten. todo: figure this out + if len(os.Args) > 1 && os.Args[1] == pb.Argname { + pb.IsAuto = true + parts := strings.Split(os.Getenv("COMP_LINE"), " ") + pb.Debug = true + log.Fprintf(os.Stderr, "\n") + pb.Debugf("MATCH Partial os.Args=%v COMP_LINE=%v", os.Args, os.Getenv("COMP_LINE")) + // log.Fprintf(os.Stdout, "jcarr") + if len(parts) > 0 { + pb.Arg0 = parts[0] + } + pb.Arg1 = os.Args[1] + os.Exit(0) + } + + // print the version and exit + if len(os.Args) > 1 && os.Args[1] == "--version" { + // if binary defined buildtime() then process standard version output here + doVersion(pb) + os.Exit(0) + } + + if os.Args[1] != "--auto-complete" { + // if the first arg is not --auto-complete, then don't go any farther + for _, s := range os.Args[1:] { + if strings.HasPrefix(s, "-") { + // option is something like --verbose + // skip these. they are not subcommands + continue + } + // found the subcommand + pb.Cmd = s + break + } + // exit here. not autocomplete + // todo: actually finish parsing the pb. is it safe to continue from here? + return + } + + // should we do auto complete here? + if len(os.Args) > 1 && os.Args[1] == "--auto-complete" { + pb.IsAuto = true + pb.Arg0 = os.Args[0] + pb.Arg1 = os.Args[1] + pb.Partial = os.Args[2] + pb.Arg3 = os.Args[3] + if len(os.Args) < 5 { + // the user is doing autocomplete on the command itself + pb.Partial = "" + pb.Cmd = "" + pb.Real = []string{""} + return + } + if pb.Partial == "''" { + pb.Partial = "" + } + // pb.Argv = os.Args[4:] + for _, s := range os.Args[4:] { + if s == "--autodebug" { + continue + } + tmp := strings.Trim(pb.Partial, "'") + if tmp == s { + // don't put pb.Partial into Argv + continue + } + pb.Real = append(pb.Real, s) + } + // set pb.Cmd to the first thing that doesn't have a '-' arg + for _, s := range pb.Real { + if strings.HasPrefix(s, "-") { + continue + } + pb.Cmd = s + break + } + if pb.Partial == "'"+pb.Cmd+"'" { + // not really a command, it's just a partially inputed string from the user + pb.Cmd = "" + } + // try to figure out what the last argv is + for _, s := range pb.Real { + p := fmt.Sprintf("'%s'", s) + if pb.Partial == p { + pb.Debugf("DEBUG: Last argv MATCHES Partial %s %s", s, p) + continue + } else { + pb.Debugf("DEBUG: Last argv DOES NOT MATCH Partial %s %s", s, p) + } + pb.Last = s + if strings.HasPrefix(s, "-") { + // skip args like -test --verbose when sending subcommands to go-args for help text + continue + } + pb.Goargs = append(pb.Goargs, s) + } + // if pb.Cmd == "" { + // pb.Cmd = strings.Join(pb.Argv, "BLAH") + // } + } + return +} 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") -} diff --git a/parseOsArgs.go b/parseOsArgs.go deleted file mode 100644 index 4959944..0000000 --- a/parseOsArgs.go +++ /dev/null @@ -1,153 +0,0 @@ -package argvpb - -// initializes logging and command line options - -import ( - "fmt" - "os" - "strings" - - "go.wit.com/log" -) - -func parseArgv(argname string) *Argv { - pb := new(Argv) - pb.Argname = argname - - // this shouldn't really happen. OS/POSIX error? - if len(os.Args) == 0 { - // fmt.Fprintf(os.Stderr, "what OS is this?\n") - return pb - } - - // there is nothing on the command line. user just ran "forge" and hit enter - if len(os.Args) == 1 { - pb.Arg0 = os.Args[0] - return pb - } - - // try to setup bash autocomplete and exit - if len(os.Args) > 1 && os.Args[1] == "--bash" { - pb.SetupAuto = true - return pb - } - - // try to setup zsh autocomplete and exit - if len(os.Args) > 1 && os.Args[1] == "--zsh" { - pb.SetupAuto = true - return pb - } - - // set debug flag if --argvdebug is passed - for _, s := range os.Args { - if s == "--argvdebug" { - pb.Debug = true - } - // deprecate - if s == "--autodebug" { - pb.Debug = true - } - } - - // wtf is this. I've forgotten. todo: figure this out - if len(os.Args) > 1 && os.Args[1] == pb.Argname { - pb.IsAuto = true - parts := strings.Split(os.Getenv("COMP_LINE"), " ") - pb.Debug = true - log.Fprintf(os.Stderr, "\n") - pb.Debugf("MATCH Partial os.Args=%v COMP_LINE=%v", os.Args, os.Getenv("COMP_LINE")) - // log.Fprintf(os.Stdout, "jcarr") - if len(parts) > 0 { - pb.Arg0 = parts[0] - } - pb.Arg1 = os.Args[1] - os.Exit(0) - } - - // print the version and exit - if len(os.Args) > 1 && os.Args[1] == "--version" { - // if binary defined buildtime() then process standard version output here - doVersion(pb) - os.Exit(0) - } - - if os.Args[1] != "--auto-complete" { - // if the first arg is not --auto-complete, then don't go any farther - for _, s := range os.Args[1:] { - if strings.HasPrefix(s, "-") { - // option is something like --verbose - // skip these. they are not subcommands - continue - } - // found the subcommand - pb.Cmd = s - break - } - // exit here. not autocomplete - // todo: actually finish parsing the pb. is it safe to continue from here? - return pb - } - - // should we do auto complete here? - if len(os.Args) > 1 && os.Args[1] == "--auto-complete" { - pb.IsAuto = true - pb.Arg0 = os.Args[0] - pb.Arg1 = os.Args[1] - pb.Partial = os.Args[2] - pb.Arg3 = os.Args[3] - if len(os.Args) < 5 { - // the user is doing autocomplete on the command itself - pb.Partial = "" - pb.Cmd = "" - pb.Real = []string{""} - return pb - } - if pb.Partial == "''" { - pb.Partial = "" - } - // pb.Argv = os.Args[4:] - for _, s := range os.Args[4:] { - if s == "--autodebug" { - continue - } - tmp := strings.Trim(pb.Partial, "'") - if tmp == s { - // don't put pb.Partial into Argv - continue - } - pb.Real = append(pb.Real, s) - } - // set pb.Cmd to the first thing that doesn't have a '-' arg - for _, s := range pb.Real { - if strings.HasPrefix(s, "-") { - continue - } - pb.Cmd = s - break - } - if pb.Partial == "'"+pb.Cmd+"'" { - // not really a command, it's just a partially inputed string from the user - pb.Cmd = "" - } - // try to figure out what the last argv is - for _, s := range pb.Real { - p := fmt.Sprintf("'%s'", s) - if pb.Partial == p { - pb.Debugf("DEBUG: Last argv MATCHES Partial %s %s", s, p) - continue - } else { - pb.Debugf("DEBUG: Last argv DOES NOT MATCH Partial %s %s", s, p) - } - pb.Last = s - if strings.HasPrefix(s, "-") { - // skip args like -test --verbose when sending subcommands to go-args for help text - continue - } - pb.Goargs = append(pb.Goargs, s) - } - // if pb.Cmd == "" { - // pb.Cmd = strings.Join(pb.Argv, "BLAH") - // } - } - return pb -} diff --git a/structs.go b/structs.go index 9ddaab1..66b8cf3 100644 --- a/structs.go +++ b/structs.go @@ -10,7 +10,7 @@ type AutoArgs struct { pb *Argv // the protobuf for the current process id int // should be unique Argv func([]string) // the function for shell autocomplete - initArgv func() (string, string, string) // this is required. gets APPNAME, BUILDTIME & VERSION + 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([]string) error // calls go-arg.ParseFlags(flags) diff --git a/theMagicOfAutocomplete.go b/theMagicOfAutocomplete.go index a4137d6..ee20b24 100644 --- a/theMagicOfAutocomplete.go +++ b/theMagicOfAutocomplete.go @@ -16,9 +16,31 @@ import ( timestamppb "google.golang.org/protobuf/types/known/timestamppb" ) +// gets APPNAME, BUILDTIME and VERSION from the application +func initAppname() { + ARGNAME, anyString, VERSION := me.initArgvFunc() + me.ARGNAME = ARGNAME + me.VERSION = VERSION + var err error + me.BUILDTIME, err = cobol.GetTime(anyString) + if err != nil { + log.Printf("TIME ERR=(%v) time=(%v) BUILTIME=(%v)\n", err, anyString, me.BUILDTIME) + } +} + func Autocomplete(dest any) *Argv { me = new(AutoArgs) // todo: redo this - findAppInfo(dest) // parses back to main() for argv info + me.pb = new(Argv) + + // makes sure the application has the + // needed functions defined, otherwise panics + verifyApplication(dest) + + // gets APPNAME, BUILDTIME and VERSION from the application + initAppname() + + // parses os.Args into a protobuf + me.pb.parseArgv() // todo: figure this out if me.guiFunc != nil { @@ -29,9 +51,6 @@ func Autocomplete(dest any) *Argv { // log.Info("no gui init") } - // parses os.Args into a protobuf - me.pb = parseArgv(me.ARGNAME) - // the argv history all := NewArgvs() diff --git a/verifyApplication.go b/verifyApplication.go new file mode 100644 index 0000000..dba5b65 --- /dev/null +++ b/verifyApplication.go @@ -0,0 +1,231 @@ +package argvpb + +import ( + "go.wit.com/log" +) + +// verify the application has the needed function calls defined +func verifyApplication(tmp interface{}) { + // START NEEDED FUNCS // 2025/10/18 (review in a few months) + if tmp, ok := tmp.(initArgvI); ok { + me.initArgvFunc = tmp.InitArgv + } 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") + } + // END NEEDED FUNCS // 2025/10/18 (review in a few months) + + // 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.(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()") + } +} + +// 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() +} + +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") +} -- cgit v1.2.3