diff options
Diffstat (limited to 'auto.Complete.go')
| -rw-r--r-- | auto.Complete.go | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/auto.Complete.go b/auto.Complete.go index 633d3e6..c99c1bf 100644 --- a/auto.Complete.go +++ b/auto.Complete.go @@ -7,8 +7,15 @@ import ( "os" "strings" "time" + + "go.wit.com/log" ) +// this is the user's application sending us strings we need to send to bash +func (pb *Auto) SendStrings(sendthis []string) { + pb.Autocomplete2(strings.Join(sendthis, " ")) +} + // todo: move everything to this? func (pb *Auto) Autocomplete3(sendthis []string) { pb.Autocomplete2(strings.Join(sendthis, " ")) @@ -59,3 +66,66 @@ func (pb *Auto) Autocomplete2(sendthis string) { } */ } + +// try out a new name. also, this whole thing is dumb and needs to be redone +func (pb *Auto) GenerateSubCommandStrings(cmd ...string) { + pb.SubCommand(cmd...) +} + +func (pb *Auto) SubCommand(cmd ...string) { + partial := strings.Trim(pb.Partial, "'") + if pb.Debug { + if myAuto.examples == nil { + pb.Debugf("WRITE DEBUG: argv.Examples() not defined") + // log.Fprintf(os.Stderr, "\n") + // log.Fprintf(os.Stderr, "examples was nil\n") + // log.Fprintf(os.Stderr, "\n") + } else { + log.Fprintf(os.Stderr, "\n") + log.Fprintf(os.Stderr, "\n") + log.Fprintf(os.Stderr, "Examples:\n") + for _, line := range strings.Split(myAuto.examples(), "\n") { + log.Fprintf(os.Stderr, " %s\n", line) + } + // log.Fprintf(os.Stderr, "\n") + } + myAuto.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, partial, cmd...) + // myAuto.pp.GetUsageForSubcommand(os.Stdout, os.Stderr, partial, cmd) + // myAuto.pp.GetUsageForSubcommand(os.Stdout, nil, partial, cmd) + } else { + f, _ := os.OpenFile("/tmp/outlook", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + myAuto.pp.WriteHelpForAutocomplete(f, os.Stdout, partial, cmd...) + // myAuto.pp.GetUsageForSubcommand(os.Stdout, nil, partial, cmd) + } + os.Exit(0) + // SubCommand(cmd) +} + +/* +func (pb *Auto) SubCommandShow() { + partial := strings.Trim(pb.Partial, "'") + if pb.Debug { + myAuto.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, partial, "show", "repo") + } else { + f, _ := os.OpenFile("/tmp/outlook", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + myAuto.pp.WriteHelpForAutocomplete(f, os.Stdout, partial, "show", "repo") + } + os.Exit(0) +} + +func (pb *Auto) SubCommand2(cmd string, addmatch []string) { + partial := strings.Trim(pb.Partial, "'") + if pb.Debug { + // myAuto.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, partial, pb.Cmd) + myAuto.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, "", "") + // myAuto.pp.GetUsageForSubcommand(os.Stdout, os.Stderr, partial, cmd) + // myAuto.pp.GetUsageForSubcommand(os.Stdout, nil, partial, cmd) + } else { + f, _ := os.OpenFile("/tmp/outlook", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + myAuto.pp.WriteHelpForAutocomplete(f, os.Stdout, partial, pb.Cmd) + // myAuto.pp.GetUsageForSubcommand(os.Stdout, nil, partial, cmd) + } + os.Exit(0) + // SubCommand(cmd) +} +*/ |
